[master] 4c7108b1b allow bgthreads to terminate only during shutdown
Dridi Boukelmoune
dridi at varni.sh
Tue Jan 14 13:37:03 UTC 2020
On Tue, Jan 14, 2020 at 1:31 PM Nils Goroll <nils.goroll at uplex.de> wrote:
>
>
> commit 4c7108b1b3a588b29b7f8e189534e132f1eb8458
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date: Tue Jan 14 14:16:49 2020 +0100
>
> allow bgthreads to terminate only during shutdown
>
> diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
> index 7ba3a0f52..d6618876d 100644
> --- a/bin/varnishd/cache/cache_main.c
> +++ b/bin/varnishd/cache/cache_main.c
> @@ -50,6 +50,7 @@
>
> #include "hash/hash_slinger.h"
>
> +int cache_shutdown = 0;
>
> volatile struct params *cache_param;
> static pthread_mutex_t cache_vrnd_mtx;
> @@ -409,8 +410,10 @@ child_main(int sigmagic, size_t altstksz)
>
> CLI_Run();
>
> + cache_shutdown = 1;
> VCA_Shutdown();
> BAN_Shutdown();
> + EXP_Shutdown();
This actually belongs in the next commit, mentioning it here in case
someone runs into this with git bisect.
> STV_close();
>
> printf("Child dies\n");
> diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
> index 7fa11d949..e96794403 100644
> --- a/bin/varnishd/cache/cache_varnishd.h
> +++ b/bin/varnishd/cache/cache_varnishd.h
> @@ -201,6 +201,7 @@ void EXP_Rearm(struct objcore *oc, vtim_real now,
> vtim_dur ttl, vtim_dur grace, vtim_dur keep);
>
> /* From cache_main.c */
> +extern int cache_shutdown;
> void BAN_Init(void);
> void BAN_Compile(void);
> void BAN_Shutdown(void);
> diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
> index 3fd20eee2..9b90dc10b 100644
> --- a/bin/varnishd/cache/cache_wrk.c
> +++ b/bin/varnishd/cache/cache_wrk.c
> @@ -86,6 +86,7 @@ wrk_bgthread(void *arg)
> struct bgthread *bt;
> struct worker wrk;
> struct VSC_main_wrk ds;
> + void *r;
>
> CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC);
> THR_SetName(bt->name);
> @@ -94,11 +95,12 @@ wrk_bgthread(void *arg)
> memset(&ds, 0, sizeof ds);
> wrk.stats = &ds;
>
> - (void)bt->func(&wrk, bt->priv);
> + r = bt->func(&wrk, bt->priv);
>
> - WRONG("BgThread terminated");
> + if (! cache_shutdown)
> + WRONG("BgThread terminated");
>
> - NEEDLESS(return (NULL));
> + return (r);
> }
>
> void
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
More information about the varnish-commit
mailing list