[hackers] [surf] implementing naive file locking. || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Sun, 9 May 2010 20:40:21 +0000 (UTC)

changeset: 196:a1d762bef415
user: Enno Boland (tox) <tox_AT_s01.de>
date: Thu May 06 13:58:49 2010 +0200
files: surf.c
description:
implementing naive file locking.

diff -r 2c2b9299e794 -r a1d762bef415 surf.c
--- a/surf.c Thu May 06 13:09:54 2010 +0200
+++ b/surf.c Thu May 06 13:58:49 2010 +0200
@@ -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 @@
 
 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 @@
         }
         soup_cookie_jar_add_cookie(j, c);
         g_object_unref(j);
+ flock(lock, LOCK_UN);
+ close(lock);
 }
 
 void
Received on Sun May 09 2010 - 20:40:21 UTC

This archive was generated by hypermail 2.2.0 : Sun May 09 2010 - 20:48:04 UTC