Return-Path: Delivered-To: apache-cvs-archive@hyperreal.org Received: (qmail 25862 invoked by uid 6000); 26 May 1999 07:12:37 -0000 Received: (qmail 25855 invoked by alias); 26 May 1999 07:12:34 -0000 Delivered-To: apache-apr-cvs@hyperreal.org Received: (qmail 25853 invoked by uid 216); 26 May 1999 07:12:32 -0000 Date: 26 May 1999 07:12:32 -0000 Message-ID: <19990526071232.25852.qmail@hyperreal.org> From: manoj@hyperreal.org To: apache-apr-cvs@hyperreal.org Subject: cvs commit: apache-apr/pthreads/src/main http_main.c Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org manoj 99/05/26 00:12:32 Modified: pthreads/src/main http_main.c Log: Cleanup and dead code removal. Revision Changes Path 1.88 +15 -73 apache-apr/pthreads/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -u -r1.87 -r1.88 --- http_main.c 1999/05/26 07:09:18 1.87 +++ http_main.c 1999/05/26 07:12:30 1.88 @@ -98,20 +98,12 @@ #include #include -#ifdef USE_SHMGET_SCOREBOARD -#include -#include -#include -#endif - #include "pthread.h" /*#include initialization if any #include threadabstractionlayer; #include networkiolayer #include lock */ -#include - /* This next function is never used. It is here to ensure that if we * make all the modules into shared libraries that core httpd still * includes the full Apache API. Without this function the objects in @@ -218,33 +210,6 @@ int ap_pipe_of_death[2]; -/* thread local storage code that isn't used right now */ - -#if 0 -/* stuff that needs thread local store in main */ -typedef struct { - jmp_buf thread_exit; - int generation; -} tls_main_t; - -static pthread_key_t tls_main_key; /* ZZZZ */ - -static tls_main_t *gettls(pthread_key_t tls_main_key) -{ - tls_main_t *tls_p; - tls_p = pthread_getspecific(tls_main_key); - if (!tls_p) { - tls_p = NULL; - fprintf(stderr, "pthread_getspecific failed\n"); - } - - return tls_p; -} -#define tls() ((tls_main_t *) gettls(tls_main_key)) /* ZZZZZ */ -#endif - - - /* *Non*-shared http_main globals... */ static server_rec *server_conf; @@ -961,24 +926,9 @@ */ } -/***************************************************************** - * Connection structures and accounting... - */ - -/* XXX - alarms will need to be blockable at some point */ - -static int alarms_blocked = 0; -static int exit_after_unblock = 0; static void just_die(int sig) -{ /* SIGHUP to child process??? */ - /* if alarms are blocked we have to wait to die otherwise we might - * end up with corruption in alloc.c's internal structures */ - if (alarms_blocked) { - exit_after_unblock = 1; - } - else { - clean_child_exit(0); - } +{ + clean_child_exit(0); } /***************************************************************** @@ -1926,9 +1876,12 @@ pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); for (i=0; i < ap_threads_per_child; i++) { - my_info = NULL; - my_info = (proc_info *)malloc(sizeof(proc_info)); + if (my_info == NULL) { + ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, + "malloc: out of memory"); + clean_child_exit(APEXIT_CHILDFATAL); + } my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; @@ -1940,13 +1893,11 @@ if (pthread_create(&thread, &thread_attr, worker_thread, my_info)) { ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, "pthread_create: unable to create worker thread"); - /* - * We failed to create a thread. Update the scoreboard, - * or it will say SERVER_STARTING forever. - */ - (void) ap_update_child_status(my_child_num, i, SERVER_DEAD, - (request_rec *) NULL); - exit(1); /* We won't always exit here, but for no this is okay */ + /* 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); } /* We let each thread update it's own scoreboard entry. This is done @@ -1969,8 +1920,8 @@ break; default: ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, - "received strange signal: %d", signal_received); - + "received impossible signal: %d", signal_received); + just_die(SIGTERM); } } @@ -1991,8 +1942,6 @@ if (one_process) { set_signals(); - /* Needed even in the one process case because lookup of the process - * pid sometimes must go through the scoreboard */ ap_scoreboard_image->parent[slot].pid = getpid(); child_main(slot); } @@ -2000,12 +1949,6 @@ Explain1("Starting new child in slot %d",slot); if ((pid = fork()) == -1) { ap_log_error(APLOG_MARK, APLOG_ERR, s, "fork: Unable to fork new process"); - - /* fork didn't succeed. Fix the scoreboard or else - * it will say SERVER_STARTING forever and ever - */ - /* (void) ap_update_child_status(slot, SERVER_DEAD, (request_rec *) NULL); - We never put SERVER_STARTING in scoreboard */ /* 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. */ @@ -2030,8 +1973,7 @@ RAISE_SIGSTOP(MAKE_CHILD); MONCONTROL(1); - /* - signal(SIGWINCH, graceful_sig_handler); + /* XXX - For an unthreaded server, a signal handler will be necessary signal(SIGTERM, just_die); */ child_main(slot);