You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by gr...@apache.org on 2004/11/27 20:33:22 UTC

svn commit: r106744 - /httpd/httpd/trunk/server/mpm/experimental/event/event.c

Author: gregames
Date: Sat Nov 27 11:33:21 2004
New Revision: 106744

URL: http://svn.apache.org/viewcvs?view=rev&rev=106744
Log:
listener_thread: no functional changes, formatting changes only

Modified:
   httpd/httpd/trunk/server/mpm/experimental/event/event.c

Modified: httpd/httpd/trunk/server/mpm/experimental/event/event.c
Url: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/experimental/event/event.c?view=diff&rev=106744&p1=httpd/httpd/trunk/server/mpm/experimental/event/event.c&r1=106743&p2=httpd/httpd/trunk/server/mpm/experimental/event/event.c&r2=106744
==============================================================================
--- httpd/httpd/trunk/server/mpm/experimental/event/event.c	(original)
+++ httpd/httpd/trunk/server/mpm/experimental/event/event.c	Sat Nov 27 11:33:21 2004
@@ -839,153 +839,152 @@
     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);
+
+        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);
+            }
+        }
 
-            rc = apr_pollset_poll(event_pollset, timeout_interval, &num,
-                                  &out_pfd);
+        if (listener_may_exit)
+            break;
 
-            if (rc != APR_SUCCESS) {
-                if (APR_STATUS_IS_EINTR(rc)) {
-                    continue;
+        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);
                 }
-                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);
+
+                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");
                 }
             }
+            else {
+                /* A Listener Socket is ready for an accept() */
+                apr_pool_t *recycled_pool = NULL;
 
-            if (listener_may_exit)
-                break;
+                lr = (ap_listen_rec *) pt->baton;
 
-            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);
-                    }
+                ap_pop_pool(&recycled_pool, worker_queue_info);
 
-                    apr_thread_mutex_lock(timeout_mutex);
-                    APR_RING_REMOVE(cs, timeout_list);
-                    apr_thread_mutex_unlock(timeout_mutex);
+                if (recycled_pool == NULL) {
+                    /* create a new transaction pool for each accepted socket */
+                    apr_allocator_t *allocator;
 
-                    rc = push2worker(out_pfd, event_pollset);
-                    if (rc != APR_SUCCESS) {
+                    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, "push2worker failed");
+                                     ap_server_conf,
+                                     "Failed to create transaction pool");
+                        signal_threads(ST_GRACEFUL);
+                        return NULL;
                     }
                 }
                 else {
-                    /* A Listener Socket is ready for an accept() */
-                    apr_pool_t *recycled_pool = NULL;
-
-                    lr = (ap_listen_rec *) pt->baton;
-
-                    ap_pop_pool(&recycled_pool, worker_queue_info);
-
-                    /* 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;
-                    }
+                    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 */
-
-            /* 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);
-
-            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;
+                    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();
+
+        /* 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;
 
-                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;