summaryrefslogtreecommitdiff
path: root/surf.c
diff options
context:
space:
mode:
authorEnno Boland (tox) <tox@s01.de>2010-05-06 13:58:49 +0200
committerEnno Boland (tox) <tox@s01.de>2010-05-06 13:58:49 +0200
commit602eb616231b4606ca09dc2f98b1c3d22b8538d5 (patch)
tree640fa7ac59e2150f3656895a4ebd436626a133c4 /surf.c
parentbef892f513db0e4c30ce16d7431f6773a44c1546 (diff)
downloadsurf-602eb616231b4606ca09dc2f98b1c3d22b8538d5.tar.gz
surf-602eb616231b4606ca09dc2f98b1c3d22b8538d5.tar.bz2
surf-602eb616231b4606ca09dc2f98b1c3d22b8538d5.zip
implementing naive file locking.
Diffstat (limited to 'surf.c')
-rw-r--r--surf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/surf.c b/surf.c
index 6e3db36..01b6fb1 100644
--- a/surf.c
+++ b/surf.c
@@ -18,6 +18,7 @@
#include <webkit/webkit.h>
#include <glib/gstdio.h>
#include <JavaScriptCore/JavaScript.h>
+#include <sys/file.h>
#define LENGTH(x) (sizeof x / sizeof x[0])
#define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK))
@@ -703,6 +704,10 @@ scroll(Client *c, const Arg *arg) {
void
setcookie(SoupCookie *c) {
+ int lock;
+
+ lock = open(cookiefile, 0);
+ flock(lock, LOCK_EX);
SoupDate *e;
SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, FALSE);
c = soup_cookie_copy(c);
@@ -712,6 +717,8 @@ setcookie(SoupCookie *c) {
}
soup_cookie_jar_add_cookie(j, c);
g_object_unref(j);
+ flock(lock, LOCK_UN);
+ close(lock);
}
void