Fixed file locking using fcntl.
authorYutao Yuan <yyt16384@gmail.com>
Mon, 12 Oct 2015 05:11:51 +0000 (13:11 +0800)
committerYutao Yuan <yyt16384@gmail.com>
Mon, 12 Oct 2015 05:11:51 +0000 (13:11 +0800)
src/cookiejar.c
src/main.h

index 9f109de..23ea525 100644 (file)
@@ -90,7 +90,7 @@ static void cookiejar_finalize(GObject *self)
 
 static void cookiejar_init(CookieJar *self)
 {
-    self->lock = open(vb.files[FILES_COOKIE], 0);
+    self->lock = open(vb.files[FILES_COOKIE], O_RDWR);
 }
 
 static void cookiejar_set_property(GObject *self, guint prop_id, const
index 562e310..7e4c035 100644 (file)
@@ -43,7 +43,7 @@
 
 #define FLOCK(fd, cmd) { \
     struct flock lock = {.l_type=cmd,.l_start=0,.l_whence=SEEK_SET,.l_len=0}; \
-    fcntl(fd, F_SETLKlock); \
+    fcntl(fd, F_SETLKW, &lock); \
 }
 
 #ifdef DEBUG