From ce5634e327b6faa90fcc947179ff55963823ba79 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 4 Jul 2014 16:26:06 +0200 Subject: [PATCH] Fix segfault when trying to stop the bnet_server thread in terminate_stored() Conflicts: bacula/src/stored/stored.c --- bacula/src/stored/stored.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index e82f53ffd0..ab548daa62 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -61,6 +61,7 @@ uint32_t VolSessionTime; char *configfile = NULL; bool init_done = false; static pthread_t server_tid; +static bool server_tid_valid = false; /* Global static variables */ static bool foreground = 0; @@ -271,6 +272,7 @@ int main (int argc, char *argv[]) /* Single server used for Director and File daemon */ server_tid = pthread_self(); + server_tid_valid = true; bnet_thread_server(me->sdaddrs, me->max_concurrent_jobs * 2 + 1, &dird_workq, handle_connection_request); exit(1); /* to keep compiler quiet */ @@ -674,8 +676,9 @@ void terminate_stored(int sig) Dmsg1(10, "No dev structure %s\n", device->device_name); } } - - bnet_stop_thread_server(server_tid); + if (server_tid_valid) { + bnet_stop_thread_server(server_tid); + } if (configfile) { free(configfile); configfile = NULL; -- 2.39.2