summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ames <gregames@apache.org>2004-11-27 20:33:21 +0100
committerGreg Ames <gregames@apache.org>2004-11-27 20:33:21 +0100
commit895bdde8f8190bfedf4109d9f492bef1e2586081 (patch)
tree2b10bf55305086f8f93704122d497c497ab489e9
parentonly need one main listener loop. (diff)
downloadapache2-895bdde8f8190bfedf4109d9f492bef1e2586081.tar.xz
apache2-895bdde8f8190bfedf4109d9f492bef1e2586081.zip
listener_thread: no functional changes, formatting changes only
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@106744 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--server/mpm/experimental/event/event.c231
1 files changed, 115 insertions, 116 deletions
diff --git a/server/mpm/experimental/event/event.c b/server/mpm/experimental/event/event.c
index 3e4af4f470..0802144768 100644
--- a/server/mpm/experimental/event/event.c
+++ b/server/mpm/experimental/event/event.c
@@ -839,153 +839,152 @@ static void *listener_thread(apr_thread_t * thd, void *dummy)
unblock_signal(LISTENER_SIGNAL);
apr_signal(LISTENER_SIGNAL, dummy_signal_handler);
- while (!listener_may_exit) {
+ while (!listener_may_exit) {
- if (requests_this_child <= 0) {
- check_infinite_requests();
- }
+ if (requests_this_child <= 0) {
+ check_infinite_requests();
+ }
- rc = apr_pollset_poll(event_pollset, timeout_interval, &num,
- &out_pfd);
+ rc = apr_pollset_poll(event_pollset, timeout_interval, &num,
+ &out_pfd);
- if (rc != APR_SUCCESS) {
- if (APR_STATUS_IS_EINTR(rc)) {
- continue;
- }
- if (!APR_STATUS_IS_TIMEUP(rc)) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf,
- "apr_pollset_poll failed. Attempting to "
- "shutdown process gracefully");
- signal_threads(ST_GRACEFUL);
- }
+ if (rc != APR_SUCCESS) {
+ if (APR_STATUS_IS_EINTR(rc)) {
+ continue;
}
+ if (!APR_STATUS_IS_TIMEUP(rc)) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf,
+ "apr_pollset_poll failed. Attempting to "
+ "shutdown process gracefully");
+ signal_threads(ST_GRACEFUL);
+ }
+ }
- if (listener_may_exit)
- break;
+ if (listener_may_exit)
+ break;
- while (num) {
- pt = (listener_poll_type *) out_pfd->client_data;
- if (pt->type == PT_CSD) {
- /* one of the sockets is readable */
- cs = (conn_state_t *) pt->baton;
- switch (cs->state) {
- case CONN_STATE_CHECK_REQUEST_LINE_READABLE:
- cs->state = CONN_STATE_READ_REQUEST_LINE;
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_ERR, rc,
- ap_server_conf,
- "event_loop: unexpected state %d",
- cs->state);
- AP_DEBUG_ASSERT(0);
- }
+ while (num) {
+ pt = (listener_poll_type *) out_pfd->client_data;
+ if (pt->type == PT_CSD) {
+ /* one of the sockets is readable */
+ cs = (conn_state_t *) pt->baton;
+ switch (cs->state) {
+ case CONN_STATE_CHECK_REQUEST_LINE_READABLE:
+ cs->state = CONN_STATE_READ_REQUEST_LINE;
+ break;
+ default:
+ ap_log_error(APLOG_MARK, APLOG_ERR, rc,
+ ap_server_conf,
+ "event_loop: unexpected state %d",
+ cs->state);
+ AP_DEBUG_ASSERT(0);
+ }
- apr_thread_mutex_lock(timeout_mutex);
- APR_RING_REMOVE(cs, timeout_list);
- apr_thread_mutex_unlock(timeout_mutex);
+ apr_thread_mutex_lock(timeout_mutex);
+ APR_RING_REMOVE(cs, timeout_list);
+ apr_thread_mutex_unlock(timeout_mutex);
- rc = push2worker(out_pfd, event_pollset);
- if (rc != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
- ap_server_conf, "push2worker failed");
- }
+ rc = push2worker(out_pfd, event_pollset);
+ if (rc != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
+ ap_server_conf, "push2worker failed");
}
- else {
- /* A Listener Socket is ready for an accept() */
- apr_pool_t *recycled_pool = NULL;
+ }
+ else {
+ /* A Listener Socket is ready for an accept() */
+ apr_pool_t *recycled_pool = NULL;
- lr = (ap_listen_rec *) pt->baton;
+ lr = (ap_listen_rec *) pt->baton;
- ap_pop_pool(&recycled_pool, worker_queue_info);
+ ap_pop_pool(&recycled_pool, worker_queue_info);
+ if (recycled_pool == NULL) {
/* create a new transaction pool for each accepted socket */
- if (recycled_pool == NULL) {
- /* create a new transaction pool for each accepted socket */
- apr_allocator_t *allocator;
-
- apr_allocator_create(&allocator);
- apr_allocator_max_free_set(allocator,
- ap_max_mem_free);
- apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
- apr_allocator_owner_set(allocator, ptrans);
- if (ptrans == NULL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
- ap_server_conf,
- "Failed to create transaction pool");
- signal_threads(ST_GRACEFUL);
- return NULL;
- }
- }
- else {
- ptrans = recycled_pool;
+ apr_allocator_t *allocator;
+
+ apr_allocator_create(&allocator);
+ apr_allocator_max_free_set(allocator,
+ ap_max_mem_free);
+ apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
+ apr_allocator_owner_set(allocator, ptrans);
+ if (ptrans == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
+ ap_server_conf,
+ "Failed to create transaction pool");
+ signal_threads(ST_GRACEFUL);
+ return NULL;
}
+ }
+ else {
+ ptrans = recycled_pool;
+ }
- apr_pool_tag(ptrans, "transaction");
+ apr_pool_tag(ptrans, "transaction");
- rc = lr->accept_func(&csd, lr, ptrans);
+ rc = lr->accept_func(&csd, lr, ptrans);
- /* later we trash rv and rely on csd to indicate success/failure */
+ /* later we trash rv and rely on csd to indicate success/failure */
- AP_DEBUG_ASSERT(rc == APR_SUCCESS || !csd);
+ AP_DEBUG_ASSERT(rc == APR_SUCCESS || !csd);
- if (rc == APR_EGENERAL) {
- /* E[NM]FILE, ENOMEM, etc */
- resource_shortage = 1;
- signal_threads(ST_GRACEFUL);
- }
+ if (rc == APR_EGENERAL) {
+ /* E[NM]FILE, ENOMEM, etc */
+ resource_shortage = 1;
+ signal_threads(ST_GRACEFUL);
+ }
- if (csd != NULL) {
- rc = ap_queue_push(worker_queue, csd, NULL, ptrans);
- if (rc != APR_SUCCESS) {
- /* trash the connection; we couldn't queue the connected
- * socket to a worker
- */
- apr_socket_close(csd);
- ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
- ap_server_conf,
- "ap_queue_push failed");
- apr_pool_clear(ptrans);
- ap_push_pool(worker_queue_info, ptrans);
- }
- else {
- have_idle_worker = 0;
- }
- }
- else {
+ if (csd != NULL) {
+ rc = ap_queue_push(worker_queue, csd, NULL, ptrans);
+ if (rc != APR_SUCCESS) {
+ /* trash the connection; we couldn't queue the connected
+ * socket to a worker
+ */
+ apr_socket_close(csd);
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rc,
+ ap_server_conf,
+ "ap_queue_push failed");
apr_pool_clear(ptrans);
ap_push_pool(worker_queue_info, ptrans);
}
- } /* if:else on pt->type */
- out_pfd++;
- num--;
- } /* while for processing poll */
+ else {
+ have_idle_worker = 0;
+ }
+ }
+ else {
+ apr_pool_clear(ptrans);
+ ap_push_pool(worker_queue_info, ptrans);
+ }
+ } /* if:else on pt->type */
+ out_pfd++;
+ num--;
+ } /* while for processing poll */
- /* XXX possible optimization: stash the current time for use as
- * r->request_time for new requests
- */
- time_now = apr_time_now();
+ /* XXX possible optimization: stash the current time for use as
+ * r->request_time for new requests
+ */
+ time_now = apr_time_now();
- /* handle timed out sockets */
- apr_thread_mutex_lock(timeout_mutex);
+ /* handle timed out sockets */
+ apr_thread_mutex_lock(timeout_mutex);
- cs = APR_RING_FIRST(&timeout_head);
- timeout_time = time_now + TIMEOUT_FUDGE_FACTOR;
- while (!APR_RING_EMPTY(&timeout_head, conn_state_t, timeout_list)
- && cs->expiration_time < timeout_time) {
- cs->state = CONN_STATE_LINGER;
+ cs = APR_RING_FIRST(&timeout_head);
+ timeout_time = time_now + TIMEOUT_FUDGE_FACTOR;
+ while (!APR_RING_EMPTY(&timeout_head, conn_state_t, timeout_list)
+ && cs->expiration_time < timeout_time) {
+ cs->state = CONN_STATE_LINGER;
- APR_RING_REMOVE(cs, timeout_list);
+ APR_RING_REMOVE(cs, timeout_list);
- rc = push2worker(&cs->pfd, event_pollset);
+ rc = push2worker(&cs->pfd, event_pollset);
- if (rc != APR_SUCCESS) {
- return NULL;
- }
- cs = APR_RING_FIRST(&timeout_head);
+ if (rc != APR_SUCCESS) {
+ return NULL;
}
- apr_thread_mutex_unlock(timeout_mutex);
+ cs = APR_RING_FIRST(&timeout_head);
+ }
+ apr_thread_mutex_unlock(timeout_mutex);
- } /* listener main loop */
+ } /* listener main loop */
ap_queue_term(worker_queue);
dying = 1;