From: Yutao Yuan Date: Mon, 12 Oct 2015 05:11:51 +0000 (+0800) Subject: Fixed file locking using fcntl. X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=c5b20658e84ae96c9945c1ca328813df8163aecc;p=vimb.git Fixed file locking using fcntl. --- 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