From: Aaron Bannert Date: Thu, 27 Dec 2001 23:40:55 +0000 (+0000) Subject: Clean up the error checking a little. Make sure we're comparing against X-Git-Tag: 2.0.30~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9348edfc43371c660fdf4737f53a4de3d475dd30;p=apache Clean up the error checking a little. Make sure we're comparing against APR_SUCCESS instead of just non-zero. Add some new error checking/reporting. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92632 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 4978e95a3d..3b31acfdf9 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -823,7 +823,17 @@ static void *start_threads(apr_thread_t *thd, void *dummy) my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; - apr_thread_create(&listener, thread_attr, listener_thread, my_info, pchild); + rv = apr_thread_create(&listener, thread_attr, listener_thread, + my_info, pchild); + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, + "apr_thread_create: unable to create worker thread"); + /* In case system resources are maxxed out, we don't want + * Apache running away with the CPU trying to fork over and + * over and over again if we exit. */ + sleep(10); + clean_child_exit(APEXIT_CHILDFATAL); + } while (1) { /* ap_threads_per_child does not include the listener thread */ for (i = 0; i < ap_threads_per_child; i++) { @@ -833,7 +843,7 @@ static void *start_threads(apr_thread_t *thd, void *dummy) continue; } - my_info = (proc_info *)malloc(sizeof(proc_info)); + my_info = (proc_info *)malloc(sizeof(proc_info)); if (my_info == NULL) { ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "malloc: out of memory"); @@ -843,15 +853,17 @@ static void *start_threads(apr_thread_t *thd, void *dummy) my_info->tid = i; my_info->sd = 0; - /* We are creating threads right now */ - ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, NULL); + /* We are creating threads right now */ + ap_update_child_status_from_indexes(my_child_num, i, + SERVER_STARTING, NULL); /* We let each thread update its own scoreboard entry. This is * done because it lets us deal with tid better. */ - if ((rv = apr_thread_create(&threads[i], thread_attr, - worker_thread, my_info, pchild))) { + rv = apr_thread_create(&threads[i], thread_attr, + worker_thread, my_info, pchild); + if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, - "apr_thread_create: unable to create worker thread"); + "apr_thread_create: unable to create worker thread"); /* In case system resources are maxxed out, we don't want Apache running away with the CPU trying to fork over and over and over again if we exit. */ @@ -954,8 +966,10 @@ static void child_main(int child_num_arg) ts->child_num_arg = child_num_arg; ts->threadattr = thread_attr; - if ((rv = apr_thread_create(&start_thread_id, thread_attr, start_threads, - ts, pchild))) { + + rv = apr_thread_create(&start_thread_id, thread_attr, start_threads, + ts, pchild); + if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, "apr_thread_create: unable to create worker thread"); /* In case system resources are maxxed out, we don't want