Hi!

Jim has encountered an issue with file-lock procedures.

The attached patch fixes this. While investigating I have noticed
that we don't actually check the locking procedures in our tests.
I shall think of a test for these (Bug for this is #1566).

Comments?


-- 
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.
From 01fb92f81104dd9904e7314930e58b5ce8f21ea1 Mon Sep 17 00:00:00 2001
From: Christian Kellermann <ck...@pestilenz.org>
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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to