diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index c809fb5..efcf6ad 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -585,7 +585,12 @@ static apr_bucket *cgi_bucket_create(request_rec *r, /* Create the pollset */ rv = apr_pollset_create(&data->pollset, 2, r->pool, 0); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "cgi: apr_pollset_create(); check system or user limits"); + return NULL; + } + fd.desc_type = APR_POLL_FILE; fd.reqevents = APR_POLLIN; @@ -593,12 +598,20 @@ static apr_bucket *cgi_bucket_create(request_rec *r, fd.desc.f = out; /* script's stdout */ fd.client_data = (void *)1; rv = apr_pollset_add(data->pollset, &fd); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "cgi: apr_pollset_add(); check system or user limits"); + return NULL; + } fd.desc.f = err; /* script's stderr */ fd.client_data = (void *)2; rv = apr_pollset_add(data->pollset, &fd); - AP_DEBUG_ASSERT(rv == APR_SUCCESS); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "cgi: apr_pollset_add(); check system or user limits"); + return NULL; + } data->r = r; b->data = data; @@ -913,6 +926,8 @@ static int cgi_handler(request_rec *r) apr_file_pipe_timeout_set(script_err, 0); b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc); + if (b == NULL) + return HTTP_INTERNAL_SERVER_ERROR; #else b = apr_bucket_pipe_create(script_in, c->bucket_alloc); #endif diff --git a/modules/proxy/mod_proxy_connect.c b/modules/proxy/mod_proxy_connect.c index fdadc56..5f416fb 100644 --- a/modules/proxy/mod_proxy_connect.c +++ b/modules/proxy/mod_proxy_connect.c @@ -268,7 +268,8 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker, if ((rv = apr_pollset_create(&pollset, 2, r->pool, 0)) != APR_SUCCESS) { apr_socket_close(sock); ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "proxy: CONNECT: error apr_pollset_create()"); + "proxy: CONNECT: error apr_pollset_create();" + " check system or user limits"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -278,11 +279,25 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker, pollfd.reqevents = APR_POLLIN; pollfd.desc.s = client_socket; pollfd.client_data = NULL; - apr_pollset_add(pollset, &pollfd); + rv = apr_pollset_add(pollset, &pollfd); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "proxy: CONNECT: error apr_pollset_add();" + " check system or user limits"); + return HTTP_INTERNAL_SERVER_ERROR; + } + + /* Add the server side to the poll */ pollfd.desc.s = sock; - apr_pollset_add(pollset, &pollfd); + rv = apr_pollset_add(pollset, &pollfd); + if (rv != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "proxy: CONNECT: error apr_pollset_add();" + " check system or user limits"); + return HTTP_INTERNAL_SERVER_ERROR; + } while (1) { /* Infinite loop until error (one side closes the connection) */ if ((rv = apr_pollset_poll(pollset, -1, &pollcnt, &signalled)) != APR_SUCCESS) { diff --git a/server/mpm/experimental/event/event.c b/server/mpm/experimental/event/event.c index a3a3c47..f76935d 100644 --- a/server/mpm/experimental/event/event.c +++ b/server/mpm/experimental/event/event.c @@ -2341,7 +2341,8 @@ static int event_pre_config(apr_pool_t * pconf, apr_pool_t * plog, if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "Couldn't create a Thread Safe Pollset. " - "Is it supported on your platform?"); + "Is it supported on your platform?" + "Also check system or user limits!"); return HTTP_INTERNAL_SERVER_ERROR; } apr_pollset_destroy(event_pollset); diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 2bbf7c3..2b3fc8c 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -499,8 +499,12 @@ static void child_main(int child_num_arg) pfd.reqevents = APR_POLLIN; pfd.client_data = lr; - /* ### check the status */ - (void) apr_pollset_add(pollset, &pfd); + status = apr_pollset_add(pollset, &pfd); + if (status != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, + "Couldn't add listener to pollset; check system or user limits"); + clean_child_exit(APEXIT_CHILDSICK); + } } mpm_state = AP_MPMQ_RUNNING; diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index accf4c7..c2bb5eb 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -593,8 +593,13 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy) free(ti); - /* ### check the status */ - (void) apr_pollset_create(&pollset, num_listensocks, tpool, 0); + rv = apr_pollset_create(&pollset, num_listensocks, tpool, 0); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, + "Couldn't create pollset in thread; check system or user limits"); + clean_child_exit(APEXIT_CHILDSICK); /* assume temporary resource issue */ + } + for (lr = ap_listeners; lr != NULL; lr = lr->next) { apr_pollfd_t pfd = { 0 }; @@ -604,8 +609,12 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy) pfd.reqevents = APR_POLLIN; pfd.client_data = lr; - /* ### check the status */ - (void) apr_pollset_add(pollset, &pfd); + rv = apr_pollset_add(pollset, &pfd); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, + "Couldn't create add listener to pollset; check system or user limits"); + clean_child_exit(APEXIT_CHILDSICK); + } } /* Unblock the signal used to wake this thread up, and set a handler for