s3: Lift the smbd_messaging_context from start_background_queue
authorVolker Lendecke <vl@samba.org>
Sun, 8 Aug 2010 13:35:31 +0000 (15:35 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 8 Aug 2010 16:09:33 +0000 (18:09 +0200)
source3/include/proto.h
source3/printing/printing.c
source3/smbd/server.c

index 8c432d26fad942d8fb4e1a40eef681b705171bcf..1b80461055c706ec80c1c62e575c27298129e386 100644 (file)
@@ -4442,7 +4442,8 @@ uint16 pjobid_to_rap(const char* sharename, uint32 jobid);
 bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid);
 void rap_jobid_delete(const char* sharename, uint32 jobid);
 bool print_backend_init(struct messaging_context *msg_ctx);
-void start_background_queue(void);
+void start_background_queue(struct tevent_context *ev,
+                           struct messaging_context *msg);
 void printing_end(void);
 
 /* The following definitions come from printing/printing_db.c  */
index 28ea4f04fe3c757808cc7a011583f7ce71b8092b..8fff73d054485e6874ccd611ffd0d498c0ffd65f 100644 (file)
@@ -1488,7 +1488,8 @@ static pid_t background_lpq_updater_pid = -1;
 /****************************************************************************
 main thread of the background lpq updater
 ****************************************************************************/
-void start_background_queue(void)
+void start_background_queue(struct tevent_context *ev,
+                           struct messaging_context *msg_ctx)
 {
        /* Use local variables for this as we don't
         * need to save the parent side of this, just
@@ -1524,9 +1525,7 @@ void start_background_queue(void)
                close(pause_pipe[0]);
                pause_pipe[0] = -1;
 
-               status = reinit_after_fork(server_messaging_context(),
-                                          server_event_context(),
-                                          procid_self(), true);
+               status = reinit_after_fork(msg_ctx, ev, procid_self(), true);
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("reinit_after_fork() failed\n"));
@@ -1534,8 +1533,7 @@ void start_background_queue(void)
                }
 
                smbd_setup_sig_term_handler();
-               smbd_setup_sig_hup_handler(server_event_context(),
-                                          server_messaging_context());
+               smbd_setup_sig_hup_handler(ev, msg_ctx);
 
                if (!serverid_register(procid_self(),
                                       FLAG_MSG_GENERAL|FLAG_MSG_SMBD
@@ -1547,12 +1545,10 @@ void start_background_queue(void)
                        exit(1);
                }
 
-               messaging_register(server_messaging_context(), NULL,
-                                  MSG_PRINTER_UPDATE, print_queue_receive);
+               messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
+                                  print_queue_receive);
 
-               fde = tevent_add_fd(server_event_context(),
-                                   server_event_context(),
-                                   pause_pipe[1], TEVENT_FD_READ,
+               fde = tevent_add_fd(ev, ev, pause_pipe[1], TEVENT_FD_READ,
                                    printing_pause_fd_handler,
                                    NULL);
                if (!fde) {
@@ -1561,7 +1557,7 @@ void start_background_queue(void)
                }
 
                DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
-               ret = tevent_loop_wait(server_event_context());
+               ret = tevent_loop_wait(ev);
                /* should not be reached */
                DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
                         ret, (ret == 0) ? "out of events" : strerror(errno)));
index 9a003a01b7181935f290f3277b46e321649384b3..b24cb35295ff0d230e076242402bc2cc70aa2b84 100644 (file)
@@ -1114,7 +1114,8 @@ extern void build_options(bool screen);
 
        if (is_daemon && !interactive
            && lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
-               start_background_queue();
+               start_background_queue(smbd_event_context(),
+                                      smbd_messaging_context());
        }
 
        if (!is_daemon) {