]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Cleanup some bnet_server calls
authorKern Sibbald <kern@sibbald.com>
Sun, 14 Oct 2018 14:08:39 +0000 (16:08 +0200)
committerKern Sibbald <kern@sibbald.com>
Sun, 14 Oct 2018 14:08:39 +0000 (16:08 +0200)
bacula/src/dird/dird.c
bacula/src/dird/ua_server.c
bacula/src/lib/workq.c
bacula/src/stored/stored.c

index 38249f3ad264000e7035102840d650cb77f1fe14..f06be79ebf1ad358ad6e833d27cd43ec9e0ff217 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -48,8 +48,8 @@ extern bool parse_dir_config(CONFIG *config, const char *configfile, int exit_co
 /* Imported subroutines */
 JCR *wait_for_next_job(char *runjob);
 void term_scheduler();
-void term_ua_server();
 void start_UA_server(dlist *addrs);
+void stop_UA_server();
 void init_job_server(int max_workers);
 void term_job_server();
 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
@@ -706,7 +706,7 @@ void terminate_dird(int sig)
       delete config;
       config = NULL;
    }
-   term_ua_server();
+   stop_UA_server();
    term_msg();                        /* terminate message handler */
    cleanup_crypto();
 
index f116fbb9059882f828f4f3a1e9c07ed6fa9a19c2..56cfecba4b95f2fe449681987d8f8f2e3bb13530 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2015 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -36,7 +36,9 @@ static void *handle_UA_client_request(void *arg);
 
 
 /* Global variables */
-static int started = FALSE;
+static bool started = false;
+static pthread_t server_tid;
+static bool server_tid_valid = false;
 static workq_t ua_workq;
 
 struct s_addr_port {
@@ -58,16 +60,27 @@ void start_UA_server(dlist *addrs)
       berrno be;
       Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s\n"), be.bstrerror(status));
    }
-   started = TRUE;
+   started = true;
    return;
 }
 
+void stop_UA_server()
+{
+   if (started && server_tid_valid) {
+      server_tid_valid = false;
+      bnet_stop_thread_server(server_tid);
+   }
+}
+
 extern "C"
 void *connect_thread(void *arg)
 {
    pthread_detach(pthread_self());
    set_jcr_in_tsd(INVALID_JCR);
 
+   server_tid = pthread_self();
+   server_tid_valid = true;
+
    /* Permit MaxConsoleConnect console connections */
    bnet_thread_server((dlist*)arg, director->MaxConsoleConnect, &ua_workq, handle_UA_client_request);
    return NULL;
@@ -216,14 +229,3 @@ void free_ua_context(UAContext *ua)
    free_bsock(ua->UA_sock);
    free(ua);
 }
-
-
-/*
- * Called from main Bacula thread
- */
-void term_ua_server()
-{
-   if (!started) {
-      return;
-   }
-}
index 115db7ebdcd03e70bf3b4179afce099d4052ea2e..b41bd4a2d12f0448d43e13c76e53cf22e315f6d6 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -101,7 +101,7 @@ int workq_init(workq_t *wq, int threads, void *(*engine)(void *arg))
    return 0;
 }
 
-/*        [B
+/*
  * Destroy a work queue
  *
  * Returns: 0 on success
index da71b2c8b366404cb0425698fe02223d88cc3183..66430b0b887e2cd34fe9566f809135b49e4d15f6 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2000-2017 Kern Sibbald
+   Copyright (C) 2000-2018 Kern Sibbald
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -779,6 +779,7 @@ void terminate_stored(int sig)
       }
    }
    if (server_tid_valid) {
+      server_tid_valid = false;
       bnet_stop_thread_server(server_tid);
    }