httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r332879 - /httpd/httpd/trunk/server/mpm/experimental/event/event.c
Date Sun, 13 Nov 2005 02:27:45 GMT
Author: brianp
Date: Sat Nov 12 18:27:44 2005
New Revision: 332879

URL: http://svn.apache.org/viewcvs?rev=332879&view=rev
Log:
Minor refactoring: move the creation of the pollset and associated
data structures outside of the listener thread function.  The point
of this is to facilitate future experiments with different concurrency
models like Leader/Followers as potential alternatives to the current
Reactor design.

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?rev=332879&r1=332878&r2=332879&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/experimental/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/experimental/event/event.c Sat Nov 12 18:27:44 2005
@@ -765,6 +765,51 @@
      */
 }
 
+static apr_status_t init_pollset(apr_pool_t *p)
+{
+    apr_status_t rv;
+    ap_listen_rec *lr;
+    listener_poll_type *pt;
+
+    rv = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT, p);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+                     "creation of the timeout mutex failed.");
+        return rv;
+    }
+
+    APR_RING_INIT(&timeout_head, conn_state_t, timeout_list);
+    APR_RING_INIT(&keepalive_timeout_head, conn_state_t, timeout_list);
+
+    /* Create the main pollset */
+    rv = apr_pollset_create(&event_pollset,
+                            ap_threads_per_child,
+                            p, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+                     "apr_pollset_create with Thread Safety failed.");
+        return rv;
+    }
+
+    for (lr = ap_listeners; lr != NULL; lr = lr->next) {
+        apr_pollfd_t *pfd = apr_palloc(p, sizeof(*pfd));
+        pt = apr_pcalloc(p, sizeof(*pt));
+        pfd->desc_type = APR_POLL_SOCKET;
+        pfd->desc.s = lr->sd;
+        pfd->reqevents = APR_POLLIN;
+
+        pt->type = PT_ACCEPT;
+        pt->baton = lr;
+
+        pfd->client_data = pt;
+
+        apr_socket_opt_set(pfd->desc.s, APR_SO_NONBLOCK, 1);
+        apr_pollset_add(event_pollset, pfd);
+    }
+
+    return APR_SUCCESS;
+}
+
 static apr_status_t push2worker(const apr_pollfd_t * pfd,
                                 apr_pollset_t * pollset)
 {
@@ -875,45 +920,13 @@
      */
 #define TIMEOUT_FUDGE_FACTOR 100000
 
-    rc = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT,
-                                 tpool);
-    if (rc != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf,
-                     "creation of the timeout mutex failed.  Attempting to "
-                     "shutdown process gracefully");
-        signal_threads(ST_GRACEFUL);
-        return NULL;
-    }
-
-    APR_RING_INIT(&timeout_head, conn_state_t, timeout_list);
-    APR_RING_INIT(&keepalive_timeout_head, conn_state_t, timeout_list);
-
-    /* Create the main pollset */
-    rc = apr_pollset_create(&event_pollset,
-                            ap_threads_per_child,
-                            tpool, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY);
+    rc = init_pollset(tpool);
     if (rc != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf,
-                     "apr_pollset_create with Thread Safety failed. "
-                     "Attempting to shutdown process gracefully");
+                     "failed to initialize pollset, "
+                     "attempting to shutdown process gracefully");
         signal_threads(ST_GRACEFUL);
         return NULL;
-    }
-
-    for (lr = ap_listeners; lr != NULL; lr = lr->next) {
-        apr_pollfd_t *pfd = apr_palloc(tpool, sizeof(*pfd));
-        pt = apr_pcalloc(tpool, sizeof(*pt));
-        pfd->desc_type = APR_POLL_SOCKET;
-        pfd->desc.s = lr->sd;
-        pfd->reqevents = APR_POLLIN;
-
-        pt->type = PT_ACCEPT;
-        pt->baton = lr;
-
-        pfd->client_data = pt;
-
-        apr_socket_opt_set(pfd->desc.s, APR_SO_NONBLOCK, 1);
-        apr_pollset_add(event_pollset, pfd);
     }
 
     /* Unblock the signal used to wake this thread up, and set a handler for



Mime
View raw message