[master] 7d9bf68 Attempt to teach the Solaris/Ports waiter how to quit

Poul-Henning Kamp phk at FreeBSD.org
Wed Jan 28 12:15:31 CET 2015


commit 7d9bf6823a1f4f48d211c7ef532f5c26c0f613a9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jan 28 11:14:54 2015 +0000

    Attempt to teach the Solaris/Ports waiter how to quit

diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index 91ddf48..bcf3ea9 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -145,9 +145,6 @@ vws_thread(void *priv)
 	struct timespec ts;
 	struct timespec *timeout;
 
-	vws->dport = port_create();
-	assert(vws->dport >= 0);
-
 	timeout = &max_ts;
 
 	while (!vws->waiter->dismantle) {
@@ -182,6 +179,12 @@ vws_thread(void *priv)
 		ret = port_getn(vws->dport, ev, MAX_EVENTS, &nevents, timeout);
 		now = VTIM_real();
 
+		if (ret < 0 && errno == EBADF) {
+			/* Our stop signal */
+			AN(vws->waiter->dismantle);
+			break;
+		}
+
 		if (ret < 0)
 			assert((errno == EINTR) || (errno == ETIME));
 
@@ -258,6 +261,8 @@ vws_init(struct waiter *w)
 	vws = w->priv;
 	INIT_OBJ(vws, VWS_MAGIC);
 	vws->waiter = w;
+	vws->dport = port_create();
+	assert(vws->dport >= 0);
 
 	AZ(pthread_create(&vws->thread, NULL, vws_thread, vws));
 }
@@ -271,8 +276,8 @@ vws_fini(struct waiter *w)
 	void *vp;
 
 	CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC);
+	AZ(close(vws->dport));
 	AZ(pthread_join(vws->thread, &vp));
-	WRONG("Not Yet Implemented");
 }
 
 /*--------------------------------------------------------------------*/



More information about the varnish-commit mailing list