s3: Lift the server_messaging_context from check_reload
[amitay/samba.git] / source3 / smbd / process.c
index b867ba1737ed0e62df299bf4e7dfe7437da6bf18..1d00e12c7e7577216b76b06a91e77271870a664c 100644 (file)
@@ -910,20 +910,20 @@ static void smbd_sig_hup_handler(struct tevent_context *ev,
                                  void *siginfo,
                                  void *private_data)
 {
+       struct messaging_context *msg_ctx = talloc_get_type_abort(
+               private_data, struct messaging_context);
        change_to_root_user();
        DEBUG(1,("Reloading services after SIGHUP\n"));
-       reload_services(False);
+       reload_services(msg_ctx, False);
 }
 
-void smbd_setup_sig_hup_handler(void)
+void smbd_setup_sig_hup_handler(struct tevent_context *ev,
+                               struct messaging_context *msg_ctx)
 {
        struct tevent_signal *se;
 
-       se = tevent_add_signal(smbd_event_context(),
-                              smbd_event_context(),
-                              SIGHUP, 0,
-                              smbd_sig_hup_handler,
-                              NULL);
+       se = tevent_add_signal(ev, ev, SIGHUP, 0, smbd_sig_hup_handler,
+                              msg_ctx);
        if (!se) {
                exit_server("failed to setup SIGHUP handler");
        }
@@ -2198,7 +2198,7 @@ void chain_reply(struct smb_request *req)
  Check if services need reloading.
 ****************************************************************************/
 
-void check_reload(time_t t)
+static void check_reload(struct messaging_context *msg_ctx, time_t t)
 {
        time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
 
@@ -2223,7 +2223,7 @@ void check_reload(time_t t)
        }
 
        if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) {
-               reload_services(True);
+               reload_services(msg_ctx, True);
                last_smb_conf_reload_time = t;
        }
 
@@ -2237,7 +2237,7 @@ void check_reload(time_t t)
                        || (t-last_printer_reload_time  < 0) ) 
                {
                        DEBUG( 3,( "Printcap cache time expired.\n"));
-                       reload_printers();
+                       reload_printers(msg_ctx);
                        last_printer_reload_time = t;
                }
        }
@@ -2435,7 +2435,8 @@ static bool keepalive_fn(const struct timeval *now, void *private_data)
  */
 static bool deadtime_fn(const struct timeval *now, void *private_data)
 {
-       struct smbd_server_connection *sconn = smbd_server_conn;
+       struct smbd_server_connection *sconn =
+               (struct smbd_server_connection *)private_data;
 
        if (sconn->using_smb2) {
                /* TODO: implement real idle check */
@@ -2443,7 +2444,7 @@ static bool deadtime_fn(const struct timeval *now, void *private_data)
                        return true;
                }
                DEBUG( 2, ( "Closing idle SMB2 connection\n" ) );
-               messaging_send(smbd_messaging_context(), procid_self(),
+               messaging_send(sconn->msg_ctx, procid_self(),
                               MSG_SHUTDOWN, &data_blob_null);
                return false;
        }
@@ -2451,7 +2452,7 @@ static bool deadtime_fn(const struct timeval *now, void *private_data)
        if ((conn_num_open(sconn) == 0)
            || (conn_idle_all(sconn, now->tv_sec))) {
                DEBUG( 2, ( "Closing idle SMB1 connection\n" ) );
-               messaging_send(smbd_messaging_context(), procid_self(),
+               messaging_send(sconn->msg_ctx, procid_self(),
                               MSG_SHUTDOWN, &data_blob_null);
                return False;
        }
@@ -2468,10 +2469,10 @@ static bool housekeeping_fn(const struct timeval *now, void *private_data)
        change_to_root_user();
 
        /* update printer queue caches if necessary */
-       update_monitored_printq_cache();
+       update_monitored_printq_cache(smbd_messaging_context());
 
        /* check if we need to reload services */
-       check_reload(time(NULL));
+       check_reload(smbd_messaging_context(), time(NULL));
 
        /* Change machine password if neccessary. */
        attempt_machine_password_change();
@@ -2807,7 +2808,7 @@ static bool fork_echo_handler(struct smbd_server_connection *sconn)
 
                close(listener_pipe[0]);
 
-               status = reinit_after_fork(smbd_messaging_context(),
+               status = reinit_after_fork(sconn->msg_ctx,
                                           smbd_event_context(),
                                           procid_self(), false);
                if (!NT_STATUS_IS_OK(status)) {
@@ -2859,7 +2860,7 @@ fail:
 
 static bool spoolss_init_cb(void *ptr)
 {
-       return nt_printing_tdb_migrate();
+       return nt_printing_tdb_migrate(smbd_messaging_context());
 }
 
 /****************************************************************************
@@ -2948,7 +2949,7 @@ void smbd_process(void)
        /* this is needed so that we get decent entries
           in smbstatus for port 445 connects */
        set_remote_machine_name(remaddr, false);
-       reload_services(true);
+       reload_services(smbd_server_conn->msg_ctx, true);
 
        /*
         * Before the first packet, check the global hosts allow/ hosts deny
@@ -3036,7 +3037,7 @@ void smbd_process(void)
 
        if (!(event_add_idle(smbd_event_context(), NULL,
                             timeval_set(IDLE_CLOSED_TIMEOUT, 0),
-                            "deadtime", deadtime_fn, NULL))) {
+                            "deadtime", deadtime_fn, smbd_server_conn))) {
                DEBUG(0, ("Could not add deadtime event\n"));
                exit(1);
        }