ctdb-daemon: Remove ctdbd_pid global variable
authorMartin Schwenke <martin@meltin.net>
Thu, 3 Jul 2014 02:29:46 +0000 (12:29 +1000)
committerAmitay Isaacs <amitay@samba.org>
Sat, 5 Jul 2014 04:51:13 +0000 (06:51 +0200)
This duplicates ctdb->ctdbd_pid.

Thanks to Sumit Bose <sbose@redhat.com> for the suggestion.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/client/ctdb_client.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_daemon.c

index 73c593fee68ab4a04bd3bcfae778d3acaba5bba2..c8ab1cd6cb1b9bac33e879fd03fac770c88400d2 100644 (file)
@@ -29,8 +29,6 @@
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 
-pid_t ctdbd_pid;
-
 /*
   allocate a packet for use in client<->daemon communication
  */
index 0481e434297547565123a77489dd11feb13e7afb..de7880bcc2725b77a7cc9da7f823e315c03617df 100644 (file)
@@ -37,11 +37,6 @@ struct srvid_request_data {
        uint32_t data;
 };
 
-/*
- * pid of the ctdbd daemon
- */
-extern pid_t ctdbd_pid;
-
 /*
   a tcp connection description
   also used by tcp_add and tcp_remove controls
index 448e7dcc98ef18bc72423be61694f0954615ec04..da2f42e9a97db44e9b740acb7fd027224987cfc7 100644 (file)
@@ -60,7 +60,7 @@ static void ctdb_time_tick(struct event_context *ev, struct timed_event *te,
 {
        struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
 
-       if (getpid() != ctdbd_pid) {
+       if (getpid() != ctdb->ctdbd_pid) {
                return;
        }
 
@@ -1070,8 +1070,10 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp,
 {
        struct timeval diff;
        struct timeval now;
+       struct ctdb_context *ctdb =
+               talloc_get_type(private_data, struct ctdb_context);
 
-       if (getpid() != ctdbd_pid) {
+       if (getpid() != ctdb->ctdbd_pid) {
                return;
        }
 
@@ -1174,10 +1176,9 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
        }
        ignore_signal(SIGPIPE);
 
-       ctdbd_pid = getpid();
-       ctdb->ctdbd_pid = ctdbd_pid;
+       ctdb->ctdbd_pid = getpid();
        DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
-                         CTDB_VERSION_STRING, ctdbd_pid));
+                         CTDB_VERSION_STRING, ctdb->ctdbd_pid));
        ctdb_create_pidfile(ctdb->ctdbd_pid);
 
        /* Make sure we log something when the daemon terminates.
@@ -1200,7 +1201,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 
        ctdb->ev = event_context_init(NULL);
        tevent_loop_allow_nesting(ctdb->ev);
-       tevent_set_trace_callback(ctdb->ev, ctdb_tevent_trace, NULL);
+       tevent_set_trace_callback(ctdb->ev, ctdb_tevent_trace, ctdb);
        ret = ctdb_init_tevent_logging(ctdb);
        if (ret != 0) {
                DEBUG(DEBUG_ALERT,("Failed to initialize TEVENT logging\n"));