Skip to content
Permalink
Browse files

allow bgthreads to terminate only during shutdown

  • Loading branch information
nigoroll committed Jan 14, 2020
1 parent 309e807 commit 4c7108b1b3a588b29b7f8e189534e132f1eb8458
Showing with 9 additions and 3 deletions.
  1. +3 −0 bin/varnishd/cache/cache_main.c
  2. +1 −0 bin/varnishd/cache/cache_varnishd.h
  3. +5 −3 bin/varnishd/cache/cache_wrk.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();
STV_close();

printf("Child dies\n");
@@ -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);
@@ -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

0 comments on commit 4c7108b

Please sign in to comment.
You can’t perform that action at this time.