implementing naive file locking.
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index 0ed831c..01b6fb1 100644 (file)
--- 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))
@@ -430,8 +431,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
                c->progress = 0;
                update(c);
                break;
-       case WEBKIT_LOAD_PROVISIONAL:
-       case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
+       default:
                break;
        }
 }
@@ -613,7 +613,7 @@ newwindow(Client *c, const Arg *arg) {
        if(!plugin)
                cmd[i++] = "-p";
        if(!loadimage)
-               cmd[i++] = "-l";
+               cmd[i++] = "-i";
        if(showxid)
                cmd[i++] = "-x";
        cmd[i++] = "--";
@@ -704,15 +704,21 @@ 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);
-       if(c && c->expires == NULL) {
+       if(c->expires == NULL) {
                e = soup_date_new_from_time_t(time(NULL) + sessiontime);
                soup_cookie_set_expires(c, e);
        }
        soup_cookie_jar_add_cookie(j, c);
        g_object_unref(j);
+       flock(lock, LOCK_UN);
+       close(lock);
 }
 
 void