diff options
author | Simo Sorce <idra@samba.org> | 2011-08-16 11:38:03 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2011-08-21 09:05:05 -0400 |
commit | f07f5c51000ed9403134e8f4eb3318ec6d572342 (patch) | |
tree | 96ec7606ef52d993b1e2f531168e2a7bf9f25319 /source3 | |
parent | 308e4e0126b7841e23a6135f884ba761eaacb58a (diff) | |
download | samba-f07f5c51000ed9403134e8f4eb3318ec6d572342.tar.gz samba-f07f5c51000ed9403134e8f4eb3318ec6d572342.tar.bz2 samba-f07f5c51000ed9403134e8f4eb3318ec6d572342.zip |
s3-spoolssd: User new prefork helpers to simplify code.
Also stop using the listening as now the prefork code properly sets
the PF_WORKER_ACCEPTING flag and it can be relied upon without having to keep
additional status around.
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.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index 76d05fca58..6f644fcd92 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -353,8 +353,6 @@ struct spoolss_children_data { struct pf_worker_data *pf; int listen_fd_size; int *listen_fds; - - bool listening; }; static void spoolss_next_client(void *pvt); @@ -385,7 +383,6 @@ static int spoolss_children_main(struct tevent_context *ev_ctx, data->msg_ctx = msg_ctx; data->listen_fd_size = listen_fd_size; data->listen_fds = listen_fds; - data->listening = false; /* loop until it is time to exit */ while (pf->status != PF_WORKER_EXITING) { @@ -409,13 +406,7 @@ static void spoolss_client_terminated(void *pvt) data = talloc_get_type_abort(pvt, struct spoolss_children_data); - if (data->pf->num_clients) { - data->pf->num_clients--; - } else { - DEBUG(2, ("Invalid num clients, aborting!\n")); - data->pf->status = PF_WORKER_EXITING; - return; - } + pfh_client_terminated(data->pf); spoolss_next_client(pvt); } @@ -436,20 +427,9 @@ static void spoolss_next_client(void *pvt) data = talloc_get_type_abort(pvt, struct spoolss_children_data); - if (data->pf->num_clients == 0) { - data->pf->status = PF_WORKER_ALIVE; - } - - if (data->pf->cmds == PF_SRV_MSG_EXIT) { - DEBUG(2, ("Parent process commands we terminate!\n")); - return; - } - - if (data->listening || - data->pf->num_clients >= data->pf->allowed_clients) { + if (!pfh_child_allowed_to_accept(data->pf)) { /* nothing to do for now we are already listening - * or reached the number of clients we are allowed - * to handle in parallel */ + * or we are not allowed to listen further */ return; } @@ -469,8 +449,6 @@ static void spoolss_next_client(void *pvt) return; } tevent_req_set_callback(req, spoolss_handle_client, next); - - data->listening = true; } static void spoolss_handle_client(struct tevent_req *req) @@ -488,8 +466,6 @@ static void spoolss_handle_client(struct tevent_req *req) /* this will free the request too */ talloc_free(client); - /* we are done listening */ - data->listening = false; if (ret != 0) { DEBUG(6, ("No client connection was available after all!\n")); |