[master] c271aef Hijack errno in Lck_CondWait

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Apr 10 14:30:07 CEST 2017


commit c271aef9b5b07f7dfc6272f75b4acc56954ea533
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Mar 13 13:04:54 2017 +0100

    Hijack errno in Lck_CondWait
    
    This should help diagnose #2253.

diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index 609971a..bf8151f 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -188,7 +188,6 @@ int __match_proto__()
 Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when)
 {
 	struct ilck *ilck;
-	int retval = 0;
 	struct timespec ts;
 	double t;
 
@@ -197,20 +196,21 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when)
 	assert(pthread_equal(ilck->owner, pthread_self()));
 	ilck->held = 0;
 	if (when == 0) {
-		AZ(pthread_cond_wait(cond, &ilck->mtx));
+		errno = pthread_cond_wait(cond, &ilck->mtx);
+		AZ(errno);
 	} else {
 		assert(when > 1e9);
 		ts.tv_nsec = (long)(modf(when, &t) * 1e9);
 		ts.tv_sec = (long)t;
-		retval = pthread_cond_timedwait(cond, &ilck->mtx, &ts);
-		assert(retval == 0 ||
-		    retval == ETIMEDOUT ||
-		    retval == EINTR);
+		errno = pthread_cond_timedwait(cond, &ilck->mtx, &ts);
+		assert(errno == 0 ||
+		    errno == ETIMEDOUT ||
+		    errno == EINTR);
 	}
 	AZ(ilck->held);
 	ilck->held = 1;
 	ilck->owner = pthread_self();
-	return (retval);
+	return (errno);
 }
 
 void



More information about the varnish-commit mailing list