[4.1] 2fdd68215 Set the task arguments under the lock

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Fri Oct 5 13:57:11 UTC 2018


commit 2fdd68215d673dc396e8bfc65f83d246baab6fdd
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Fri Jul 13 12:02:23 2018 +0100

    Set the task arguments under the lock
    
    I've been torturing varnish with this change for some time and was
    not able to reproduce the problem.
    
    Should fix #2719.

diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 2355752ab..3e3fe5dcf 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -222,13 +222,12 @@ Pool_Task_Arg(struct worker *wrk, enum task_prio how, task_func_t *func,
 		wrk2 = wrk;
 		retval = 0;
 	}
-	Lck_Unlock(&pp->mtx);
 	AZ(wrk2->task.func);
-
 	assert(arg_len <= WS_Reserve(wrk2->aws, arg_len));
 	memcpy(wrk2->aws->f, arg, arg_len);
 	wrk2->task.func = func;
 	wrk2->task.priv = wrk2->aws->f;
+	Lck_Unlock(&pp->mtx);
 	if (retval)
 		AZ(pthread_cond_signal(&wrk2->cond));
 	return (retval);


More information about the varnish-commit mailing list