changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: webcookies: only sync the jar when dirty on clunk

changeset 4213: 58775c177bda
parent 4212: 879ef1aac380
child 4214: d9f445833252
author: cinap_lenrek@felloff.net
date: Fri, 16 Jan 2015 04:46:52 +0100
files: sys/src/cmd/webcookies.c
description: webcookies: only sync the jar when dirty on clunk

avoid sync the jar file when fids get clunked.
the only reason to sync the jar on clunk is when it has
been marked dirty (cookies added or deleted) and we
want to flush the changes to disk.
     1.1--- a/sys/src/cmd/webcookies.c
     1.2+++ b/sys/src/cmd/webcookies.c
     1.3@@ -483,8 +483,9 @@ closejar(Jar *jar)
     1.4 	if(jar == nil)
     1.5 		return;
     1.6 	expirejar(jar, 0);
     1.7-	if(syncjar(jar) < 0)
     1.8-		fprint(2, "warning: cannot rewrite cookie jar: %r\n");
     1.9+	if(jar->dirty)
    1.10+		if(syncjar(jar) < 0)
    1.11+			fprint(2, "warning: cannot rewrite cookie jar: %r\n");
    1.12 
    1.13 	for(i=0; i<jar->nc; i++)
    1.14 		freecookie(&jar->c[i]);
    1.15@@ -1208,7 +1209,8 @@ fsdestroyfid(Fid *fid)
    1.16 				delcookie(jar, &jar->c[i]);
    1.17 		break;
    1.18 	}
    1.19-	syncjar(jar);
    1.20+	if(jar->dirty)
    1.21+		syncjar(jar);
    1.22 	free(a->dom);
    1.23 	free(a->path);
    1.24 	free(a->inhttp);