s3-prefork: Fix use of child id.
authorSimo Sorce <idra@samba.org>
Tue, 9 Aug 2011 20:44:52 +0000 (16:44 -0400)
committerAndreas Schneider <asn@samba.org>
Wed, 10 Aug 2011 16:14:05 +0000 (18:14 +0200)
Children Ids must start at 1 as 0 represent the father.
Also fix callbacks that restart logs to use a procedd global variable that
holds the Id so that they work correctly both fot the parent process and the
children.

Signed-off-by: Andreas Schneider <asn@samba.org>
source3/lib/server_prefork.c
source3/printing/spoolssd.c

index 54a0dbc17142effbc4b9217ca2b578704b2b2e36..501fbc1b884a63d707f9f79d140e512edf4d53a4 100644 (file)
@@ -121,7 +121,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 
                        pfp->pool[i].status = PF_WORKER_IDLE;
                        ret = pfp->main_fn(ev_ctx, msg_ctx,
-                                          &pfp->pool[i], i,
+                                          &pfp->pool[i], i + 1,
                                           pfp->listen_fd_size,
                                           pfp->listen_fds,
                                           pfp->lock_fd,
@@ -206,7 +206,7 @@ int prefork_add_children(struct tevent_context *ev_ctx,
 
                        pfp->pool[i].status = PF_WORKER_IDLE;
                        ret = pfp->main_fn(ev_ctx, msg_ctx,
-                                          &pfp->pool[i], i,
+                                          &pfp->pool[i], i + 1,
                                           pfp->listen_fd_size,
                                           pfp->listen_fds,
                                           pfp->lock_fd,
index 4379179f02cfc78fb51cb9ad8c61bbecd2ff00e3..ed529888f83a7b6a6df84836de13d60572e30f68 100644 (file)
@@ -51,6 +51,7 @@ static int spoolss_min_children;
 static int spoolss_max_children;
 static int spoolss_spawn_rate;
 static int spoolss_prefork_status;
+static int spoolss_child_id = 0;
 
 static void spoolss_prefork_config(void)
 {
@@ -147,8 +148,10 @@ static void update_conf(struct tevent_context *ev,
        lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
        reload_printers(ev, msg);
 
-       spoolss_reopen_logs(0);
-       spoolss_prefork_config();
+       spoolss_reopen_logs(spoolss_child_id);
+       if (spoolss_child_id == 0) {
+               spoolss_prefork_config();
+       }
 }
 
 static void smb_conf_updated(struct messaging_context *msg,
@@ -243,7 +246,6 @@ static bool spoolss_shutdown_cb(void *ptr)
 struct spoolss_chld_sig_hup_ctx {
        struct messaging_context *msg_ctx;
        struct pf_worker_data *pf;
-       int child_id;
 };
 
 static void spoolss_chld_sig_hup_handler(struct tevent_context *ev,
@@ -266,13 +268,12 @@ static void spoolss_chld_sig_hup_handler(struct tevent_context *ev,
        change_to_root_user();
        DEBUG(1,("Reloading printers after SIGHUP\n"));
        reload_printers(ev, shc->msg_ctx);
-       spoolss_reopen_logs(shc->child_id);
+       spoolss_reopen_logs(spoolss_child_id);
 }
 
 static bool spoolss_setup_chld_hup_handler(struct tevent_context *ev_ctx,
                                           struct messaging_context *msg_ctx,
-                                          struct pf_worker_data *pf,
-                                          int child_id)
+                                          struct pf_worker_data *pf)
 {
        struct spoolss_chld_sig_hup_ctx *shc;
        struct tevent_signal *se;
@@ -282,7 +283,6 @@ static bool spoolss_setup_chld_hup_handler(struct tevent_context *ev_ctx,
                DEBUG(1, ("failed to setup SIGHUP handler"));
                return false;
        }
-       shc->child_id = child_id;
        shc->pf = pf;
        shc->msg_ctx = msg_ctx;
 
@@ -314,9 +314,10 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
                smb_panic("reinit_after_fork() failed");
        }
 
+       spoolss_child_id = child_id;
        spoolss_reopen_logs(child_id);
 
-       ok = spoolss_setup_chld_hup_handler(ev_ctx, msg_ctx, pf, child_id);
+       ok = spoolss_setup_chld_hup_handler(ev_ctx, msg_ctx, pf);
        if (!ok) {
                return false;
        }
@@ -359,7 +360,6 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
 struct spoolss_children_data {
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
-       int child_id;
        struct pf_worker_data *pf;
        int listen_fd_size;
        int *listen_fds;
@@ -392,7 +392,6 @@ static int spoolss_children_main(struct tevent_context *ev_ctx,
        if (!data) {
                return 1;
        }
-       data->child_id = child_id;
        data->pf = pf;
        data->ev_ctx = ev_ctx;
        data->msg_ctx = msg_ctx;