From c5b20658e84ae96c9945c1ca328813df8163aecc Mon Sep 17 00:00:00 2001 From: Yutao Yuan Date: Mon, 12 Oct 2015 13:11:51 +0800 Subject: [PATCH] Fixed file locking using fcntl. --- src/cookiejar.c | 2 +- src/main.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cookiejar.c b/src/cookiejar.c index 9f109de..23ea525 100644 --- a/src/cookiejar.c +++ b/src/cookiejar.c @@ -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 diff --git a/src/main.h b/src/main.h index 562e310..7e4c035 100644 --- a/src/main.h +++ b/src/main.h @@ -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_SETLK, lock); \ + fcntl(fd, F_SETLKW, &lock); \ } #ifdef DEBUG -- 2.20.1