]> arthur.barton.de Git - netatalk.git/commitdiff
Lock volume files while reading them
authorFrank Lahm <franklahm@googlemail.com>
Mon, 21 Mar 2011 13:53:19 +0000 (14:53 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 21 Mar 2011 13:53:19 +0000 (14:53 +0100)
NEWS
etc/afpd/volume.c

diff --git a/NEWS b/NEWS
index 169c8f2fa9379cdfae83be56d84af2502cbaa209..d1ed03f2f8190fc9f382c6bcee1d477ab692a527 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Changes in XXX
 * FIX: afpd: generate mersenne primes for DHX2 UAM once at startup,
        not for every login
 * FIX: Support for platforms that do not have the *at functions
+* UPD: afpd: put POSIX write lock on volume files while reading them
 
 Changes in 2.2beta3
 ===================
index bcc2468f069dd057f37974ad50838a278239a08f..a7a62e852211ef6d42ccc8121e9c9b2565516a90 100644 (file)
@@ -1199,6 +1199,14 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int us
         p1->mtime = st.st_mtime;
     }
 
+    if ((read_lock(fd, 0, SEEK_SET, 0)) != 0) {
+        LOG(log_error, logtype_afpd, "readvolfile: can't lock volume file \"%s\"", path);
+        if ( fclose( fp ) != 0 ) {
+            LOG(log_error, logtype_afpd, "readvolfile: fclose: %s", strerror(errno) );
+        }
+        return -1;
+    }
+
     memset(save_options, 0, sizeof(save_options));
 
     /* Enable some default options for all volumes */