implementing naive file locking.

This commit is contained in:
Enno Boland (tox) 2010-05-06 13:58:49 +02:00
parent bef892f513
commit 602eb61623
1 changed files with 7 additions and 0 deletions

7
surf.c
View File

@ -18,6 +18,7 @@
#include <webkit/webkit.h> #include <webkit/webkit.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <JavaScriptCore/JavaScript.h> #include <JavaScriptCore/JavaScript.h>
#include <sys/file.h>
#define LENGTH(x) (sizeof x / sizeof x[0]) #define LENGTH(x) (sizeof x / sizeof x[0])
#define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK)) #define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK))
@ -703,6 +704,10 @@ scroll(Client *c, const Arg *arg) {
void void
setcookie(SoupCookie *c) { setcookie(SoupCookie *c) {
int lock;
lock = open(cookiefile, 0);
flock(lock, LOCK_EX);
SoupDate *e; SoupDate *e;
SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, FALSE); SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, FALSE);
c = soup_cookie_copy(c); c = soup_cookie_copy(c);
@ -712,6 +717,8 @@ setcookie(SoupCookie *c) {
} }
soup_cookie_jar_add_cookie(j, c); soup_cookie_jar_add_cookie(j, c);
g_object_unref(j); g_object_unref(j);
flock(lock, LOCK_UN);
close(lock);
} }
void void