*/
}
+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)
{
*/
#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
* it.
*/