r4955 - in trunk/varnish-cache: bin/varnishlog include lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Mon Jun 14 11:17:49 CEST 2010


Author: phk
Date: 2010-06-14 11:17:49 +0200 (Mon, 14 Jun 2010)
New Revision: 4955

Modified:
   trunk/varnish-cache/bin/varnishlog/varnishlog.c
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnishapi/vsl.c
   trunk/varnish-cache/lib/libvarnishapi/vsm.c
   trunk/varnish-cache/lib/libvarnishapi/vsm_api.h
Log:
Make VSL_Dispatch reopen the vsm when idle-timeout kicks in.



Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishlog/varnishlog.c	2010-06-14 08:40:04 UTC (rev 4954)
+++ trunk/varnish-cache/bin/varnishlog/varnishlog.c	2010-06-14 09:17:49 UTC (rev 4955)
@@ -194,7 +194,7 @@
 }
 
 static void
-do_order(const struct VSM_data *vd, int argc, char * const *argv)
+do_order(struct VSM_data *vd, int argc, char * const *argv)
 {
 	int i;
 	const char *error;

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2010-06-14 08:40:04 UTC (rev 4954)
+++ trunk/varnish-cache/include/varnishapi.h	2010-06-14 09:17:49 UTC (rev 4955)
@@ -250,7 +250,7 @@
 struct VSM_data;
 void VSL_Select(const struct VSM_data *vd, unsigned tag);
 void VSL_NonBlocking(const struct VSM_data *vd, int nb);
-int VSL_Dispatch(const struct VSM_data *vd, vsl_handler *func, void *priv);
+int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv);
 int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp);
 extern const char *VSL_tags[256];
 

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-14 08:40:04 UTC (rev 4954)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-14 09:17:49 UTC (rev 4955)
@@ -266,7 +266,7 @@
 /*--------------------------------------------------------------------*/
 
 int
-VSL_Dispatch(const struct VSM_data *vd, vsl_handler *func, void *priv)
+VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv)
 {
 	struct vsl *vsl;
 	int i;
@@ -279,6 +279,8 @@
 
 	while (1) {
 		i = VSL_NextLog(vd, &p);
+		if (i == 0 && VSM_ReOpen(vd, 0) == 1)
+			continue;
 		if (i != 1)
 			return (i);
 		u = VSL_ID(p);
@@ -325,21 +327,15 @@
 
 /*--------------------------------------------------------------------*/
 
-int
-VSL_Open(struct VSM_data *vd, int diag)
+void
+vsl_open_cb(struct VSM_data *vd)
 {
 	struct vsl *vsl;
 	struct vsm_chunk *sha;
-	int i;
 
 	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
 	vsl = vd->vsl;
 	CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
-
-	i = VSM_Open(vd, diag);
-	if (i)
-		return (i);
-
 	sha = vsm_find_alloc(vd, VSL_CLASS, "", "");
 	assert(sha != NULL);
 
@@ -349,6 +345,24 @@
 
 	vsl->last_seq = vsl->log_start[0];
 	VRMB();
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+VSL_Open(struct VSM_data *vd, int diag)
+{
+	struct vsl *vsl;
+	int i;
+
+	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
+	vsl = vd->vsl;
+	CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
+
+	i = VSM_Open(vd, diag);
+	if (i)
+		return (i);
+
 	if (!vsl->d_opt && vsl->r_fd == -1) {
 		while (*vsl->log_ptr != VSL_ENDMARKER)
 			vsl->log_ptr = VSL_NEXT(vsl->log_ptr);

Modified: trunk/varnish-cache/lib/libvarnishapi/vsm.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsm.c	2010-06-14 08:40:04 UTC (rev 4954)
+++ trunk/varnish-cache/lib/libvarnishapi/vsm.c	2010-06-14 09:17:49 UTC (rev 4955)
@@ -191,6 +191,9 @@
 	while(slh.alloc_seq == 0)
 		(void)usleep(50000);		/* XXX limit total sleep */
 	vd->alloc_seq = slh.alloc_seq;
+
+	if (vd->vsl != NULL)
+		vsl_open_cb(vd);
 	return (0);
 }
 

Modified: trunk/varnish-cache/lib/libvarnishapi/vsm_api.h
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsm_api.h	2010-06-14 08:40:04 UTC (rev 4954)
+++ trunk/varnish-cache/lib/libvarnishapi/vsm_api.h	2010-06-14 09:17:49 UTC (rev 4955)
@@ -64,3 +64,4 @@
 
 void vsc_delete(struct VSM_data *vd);
 void vsl_delete(struct VSM_data *vd);
+void vsl_open_cb(struct VSM_data *vd);




More information about the varnish-commit mailing list