summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-08-16 16:36:43 -0400
committerSimo Sorce <idra@samba.org>2011-08-21 09:05:06 -0400
commit72746498a4b532e0a30a955dd1b3b854d2de0c59 (patch)
tree2b658e1da36ba276f350093ca1438b472ad74131 /source3
parent5c1a8dcf8e192caa9963e4e3001f6546bcfde538 (diff)
downloadsamba-72746498a4b532e0a30a955dd1b3b854d2de0c59.tar.gz
samba-72746498a4b532e0a30a955dd1b3b854d2de0c59.tar.bz2
samba-72746498a4b532e0a30a955dd1b3b854d2de0c59.zip
s3-spoolssd: Send a message to the parent when we accept a connection
Every time we accept a connection wanr the parent, so it can run management routines and reallocate more resources if necessary. Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/spoolssd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index 6f644fcd92..b833529f8f 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -39,6 +39,7 @@
#define SPOOLSS_PIPE_NAME "spoolss"
#define DAEMON_NAME "spoolssd"
+static struct server_id parent_id;
static struct prefork_pool *spoolss_pool = NULL;
static int spoolss_child_id = 0;
@@ -455,6 +456,7 @@ static void spoolss_handle_client(struct tevent_req *req)
{
struct spoolss_children_data *data;
struct spoolss_new_client *client;
+ const DATA_BLOB ping = data_blob_null;
int ret;
int sd;
@@ -472,6 +474,10 @@ static void spoolss_handle_client(struct tevent_req *req)
return;
}
+ /* Warn parent that our status changed */
+ messaging_send(data->msg_ctx, parent_id,
+ MSG_PREFORK_CHILD_EVENT, &ping);
+
DEBUG(2, ("Spoolss preforked child %d got client connection!\n",
(int)(data->pf->pid)));
@@ -504,6 +510,20 @@ static void check_updater_child(void)
}
}
+static void child_ping(struct messaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+ struct tevent_context *ev_ctx;
+
+ ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
+
+ DEBUG(10, ("Got message that a child changed status.\n"));
+ pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
+}
+
static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct timeval current_time);
@@ -654,6 +674,9 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
smb_panic("reinit_after_fork() failed");
}
+ /* save the parent process id so the children can use it later */
+ parent_id = procid_self();
+
spoolss_reopen_logs(0);
pfh_daemon_config(DAEMON_NAME,
&pf_spoolss_cfg,
@@ -714,6 +737,8 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
print_queue_forward);
messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
pcap_updated);
+ messaging_register(msg_ctx, ev_ctx,
+ MSG_PREFORK_CHILD_EVENT, child_ping);
/* As soon as messaging is up check if pcap has been loaded already.
* If so then we probably missed a message and should load_printers()