From 01fb92f81104dd9904e7314930e58b5ce8f21ea1 Mon Sep 17 00:00:00 2001 From: Christian Kellermann Date: Fri, 30 Nov 2018 22:55:24 +0100 Subject: [PATCH] Test for port direction when setting up flock struct This fixes #1565. We create a read lock only on input ports, output ports and bidirectional ports will get a write lock. --- posixunix.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posixunix.scm b/posixunix.scm index a85f9dce..ad1f42c4 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -990,7 +990,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime) (if (eq? #t len) (set! len 0) (##sys#check-exact-integer len loc) ) - (##core#inline "C_flock_setup" (if (##sys#slot port 1) _f_rdlck _f_wrlck) start len) + (##core#inline "C_flock_setup" (if (= (##sys#slot port 1) 1) _f_rdlck _f_wrlck) start len) (##sys#make-structure 'lock port start len) ) ) (define (err msg lock loc) (posix-error #:file-error loc msg (##sys#slot lock 1) (##sys#slot lock 2) (##sys#slot lock 3)) ) -- 2.19.1