s3: Remove a call to procid_self()
[kai/samba.git] / source3 / nmbd / nmbd.c
index 63a5681e9d3db9a24f0e6a7457d5144102e3a0f9..afc7bbdf413d970a8c8b488dc3270a3d7c684d7e 100644 (file)
@@ -61,7 +61,7 @@ static struct messaging_context *nmbd_messaging_context(void)
  Handle a SIGTERM in band.
  **************************************************************************** */
 
-static void terminate(void)
+static void terminate(struct messaging_context *msg)
 {
        DEBUG(0,("Got SIGTERM: going down...\n"));
 
@@ -78,7 +78,7 @@ static void terminate(void)
        kill_async_dns_child();
 
        gencache_stabilize();
-       serverid_deregister(procid_self());
+       serverid_deregister(messaging_server_id(msg));
 
        pidfile_unlink();
 
@@ -92,10 +92,13 @@ static void nmbd_sig_term_handler(struct tevent_context *ev,
                                  void *siginfo,
                                  void *private_data)
 {
-       terminate();
+       struct messaging_context *msg = talloc_get_type_abort(
+               private_data, struct messaging_context);
+
+       terminate(msg);
 }
 
-static bool nmbd_setup_sig_term_handler(void)
+static bool nmbd_setup_sig_term_handler(struct messaging_context *msg)
 {
        struct tevent_signal *se;
 
@@ -103,7 +106,7 @@ static bool nmbd_setup_sig_term_handler(void)
                               nmbd_event_context(),
                               SIGTERM, 0,
                               nmbd_sig_term_handler,
-                              NULL);
+                              msg);
        if (!se) {
                DEBUG(0,("failed to setup SIGTERM handler"));
                return false;
@@ -125,13 +128,15 @@ static void nmbd_sig_hup_handler(struct tevent_context *ev,
                                 void *siginfo,
                                 void *private_data)
 {
+       struct messaging_context *msg = talloc_get_type_abort(
+               private_data, struct messaging_context);
+
        DEBUG(0,("Got SIGHUP dumping debug info.\n"));
-       msg_reload_nmbd_services(nmbd_messaging_context(),
-                                NULL, MSG_SMB_CONF_UPDATED,
-                                procid_self(), NULL);
+       msg_reload_nmbd_services(msg, NULL, MSG_SMB_CONF_UPDATED,
+                                messaging_server_id(msg), NULL);
 }
 
-static bool nmbd_setup_sig_hup_handler(void)
+static bool nmbd_setup_sig_hup_handler(struct messaging_context *msg)
 {
        struct tevent_signal *se;
 
@@ -139,7 +144,7 @@ static bool nmbd_setup_sig_hup_handler(void)
                               nmbd_event_context(),
                               SIGHUP, 0,
                               nmbd_sig_hup_handler,
-                              NULL);
+                              msg);
        if (!se) {
                DEBUG(0,("failed to setup SIGHUP handler"));
                return false;
@@ -158,7 +163,7 @@ static void nmbd_terminate(struct messaging_context *msg,
                           struct server_id server_id,
                           DATA_BLOB *data)
 {
-       terminate();
+       terminate(msg);
 }
 
 /**************************************************************************** **
@@ -459,7 +464,7 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
  The main select loop.
  **************************************************************************** */
 
-static void process(void)
+static void process(struct messaging_context *msg)
 {
        bool run_election;
 
@@ -480,8 +485,7 @@ static void process(void)
                 * (nmbd_packets.c)
                 */
 
-               if (listen_for_packets(nmbd_messaging_context(),
-                                      run_election)) {
+               if (listen_for_packets(msg, run_election)) {
                        TALLOC_FREE(frame);
                        return;
                }
@@ -925,9 +929,9 @@ static bool open_sockets(bool isdaemon, int port)
                exit(1);
        }
 
-       if (!nmbd_setup_sig_term_handler())
+       if (!nmbd_setup_sig_term_handler(nmbd_messaging_context()))
                exit(1);
-       if (!nmbd_setup_sig_hup_handler())
+       if (!nmbd_setup_sig_hup_handler(nmbd_messaging_context()))
                exit(1);
 
        /* get broadcast messages */
@@ -1013,7 +1017,7 @@ static bool open_sockets(bool isdaemon, int port)
         }
 
        TALLOC_FREE(frame);
-       process();
+       process(nmbd_messaging_context());
 
        kill_async_dns_child();
        return(0);