r2428 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Feb 5 10:46:30 CET 2008


Author: phk
Date: 2008-02-05 10:46:30 +0100 (Tue, 05 Feb 2008)
New Revision: 2428

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_cli.c
Log:
We assume that all CLI processing in the child process happens in the
same thread (the main thread in fact).

Add an assert facility to mark the affected functions, just to make sure
nobody (else) gets an anciety attack over missing locking.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2008-02-05 09:31:00 UTC (rev 2427)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2008-02-05 09:46:30 UTC (rev 2428)
@@ -470,6 +470,8 @@
 
 /* cache_cli.c [CLI] */
 void CLI_Init(void);
+extern pthread_t cli_thread;
+#define ASSERT_CLI() do {assert(phtread_self() == cli_thread);} while (0)
 
 /* cache_expiry.c */
 void EXP_Insert(struct object *o);

Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_cli.c	2008-02-05 09:31:00 UTC (rev 2427)
+++ trunk/varnish-cache/bin/varnishd/cache_cli.c	2008-02-05 09:46:30 UTC (rev 2428)
@@ -44,6 +44,8 @@
 #include "vsb.h"
 #include "heritage.h"
 
+pthread_t	cli_thread;
+
 /*--------------------------------------------------------------------*/
 
 static void
@@ -92,6 +94,7 @@
 	cli = &clis;
 	memset(cli, 0, sizeof *cli);
 
+	cli_thread = pthread_self();
 	cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
 	XXXAN(cli->sb);
 	lbuf = 4096;




More information about the varnish-commit mailing list