r4569 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Feb 17 10:24:31 CET 2010


Author: phk
Date: 2010-02-17 10:24:31 +0100 (Wed, 17 Feb 2010)
New Revision: 4569

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
In one of the the first threads we launch, test that errno is thread local
and working, and panic with a somewhat usable message if not.

PS: And boy, are you screwed if my test sneaks though a kernel bug...



Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2010-02-16 21:41:17 UTC (rev 4568)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2010-02-17 09:24:31 UTC (rev 4569)
@@ -404,9 +404,21 @@
 	volatile unsigned u;
 	double t_idle;
 	struct varnish_stats vsm, *vs;
+	int errno_is_multi_threaded;
 
 	THR_SetName("wrk_herdtimer");
 
+	/*
+	 * This is one of the first threads created, test to see that
+	 * errno is really per thread.  If this fails, your C-compiler
+	 * needs some magic argument (-mt, -pthread, -pthreads etc etc).
+	 */
+	errno = 0;
+	AN(unlink("/"));		/* This had better fail */
+	errno_is_multi_threaded = errno;
+	assert(errno_is_multi_threaded != 0);
+	assert(errno == EISDIR);
+
 	memset(&vsm, 0, sizeof vsm);
 	vs = &vsm;
 



More information about the varnish-commit mailing list