From: David Reid Date: Fri, 16 Nov 2001 01:32:20 +0000 (+0000) Subject: Add the serialization stuff for BeOS to get us building again. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0952f1b51c5e007a56708fd03cf1eb7f75eddd7;p=thirdparty%2Fapache%2Fhttpd.git Add the serialization stuff for BeOS to get us building again. Also, stop detaching as it causes a segfault somewhere in the kernel. I'll try to find out where and see why... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@91975 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/include/ap_config.h b/src/include/ap_config.h index d63e52887b8..daeccae7657 100644 --- a/src/include/ap_config.h +++ b/src/include/ap_config.h @@ -895,6 +895,10 @@ typedef int rlim_t; #undef PLATFORM #define PLATFORM "BeOS" #include +#include + +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT #define NO_WRITEV #define NO_KILLPG @@ -905,9 +909,13 @@ typedef int rlim_t; #elif defined(BONE) #undef PLATFORM #define PLATFORM "BeOS BONE" +#include + #define NO_KILLPG #define NEED_INITGROUPS #define S_IEXEC S_IXUSR +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT #elif defined(_CX_SX) #define JMP_BUF sigjmp_buf @@ -1225,6 +1233,9 @@ int setrlimit(int, struct rlimit *); #if defined(USE_TPF_CORE_SERIALIZED_ACCEPT) && !defined(HAVE_TPF_CORE_SERIALIZED_ACCEPT) #define HAVE_TPF_CORE_SERIALIZED_ACCEPT #endif +#if defined(USE_BEOS_SERIALIZED_ACCEPT) && !defined(HAVE_BEOS_SERIALIZED_ACCEPT) +#define HAVE_BEOS_SERIALIZED_ACCEPT +#endif #if defined(USE_NONE_SERIALIZED_ACCEPT) && !defined(HAVE_NONE_SERIALIZED_ACCEPT) #define HAVE_NONE_SERIALIZED_ACCEPT #endif diff --git a/src/main/http_core.c b/src/main/http_core.c index a5ba80ecbe8..3072b194b0e 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -3251,6 +3251,9 @@ static const command_rec core_cmds[] = { #ifdef HAVE_TPF_CORE_SERIALIZED_ACCEPT "'tpfcore' " #endif +#ifdef HAVE_BEOS_SERIALIZED_ACCEPT + "'beos_sem' " +#endif #ifdef HAVE_NONE_SERIALIZED_ACCEPT "'none' " #endif diff --git a/src/main/http_main.c b/src/main/http_main.c index 425e2d88d29..3d859b08ff3 100644 --- a/src/main/http_main.c +++ b/src/main/http_main.c @@ -1104,6 +1104,65 @@ accept_mutex_methods_s accept_mutex_tpfcore_s = { }; #endif +#ifdef HAVE_BEOS_SERIALIZED_ACCEPT +static sem_id _sem = -1; +static int locked = 0; + +static void accept_mutex_child_cleanup_beos(void *foo) +{ + if (_sem > 0 && locked) + release_sem(_sem); +} + +static void accept_mutex_child_init_beos(pool *p) +{ + ap_register_cleanup(p, NULL, accept_mutex_child_cleanup_beos, ap_null_cleanup); + locked = 0; +} + +static void accept_mutex_cleanup_beos(void *foo) +{ + if (_sem > 0) + delete_sem(_sem); +} + +static void accept_mutex_init_beos(pool *p) +{ + _sem = create_sem(1, "httpd_accept"); + if (_sem < 0) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf, + "Parent cannot create lock semaphore, sem=%ld", _sem); + exit(APEXIT_INIT); + } + + ap_register_cleanup(p, NULL, accept_mutex_cleanup_beos, ap_null_cleanup); +} +void accept_mutex_on_beos(void) +{ + if (locked == 0) { + if (acquire_sem(_sem) == B_OK) + locked = 1; + } +} + +static void accept_mutex_off_beos(void) +{ + if (locked == 1) { + if (release_sem(_sem) == B_OK) + locked = 0; + } +} + +accept_mutex_methods_s accept_mutex_beos_s = { + accept_mutex_child_init_beos, + accept_mutex_init_beos, + accept_mutex_on_beos, + accept_mutex_off_beos, + "beos_sem" +}; +#endif /* HAVE_BEOS_SERIALIZED_ACCEPT */ + + /* Generally, HAVE_NONE_SERIALIZED_ACCEPT simply won't work but * for testing purposes, here it is... */ #if defined HAVE_NONE_SERIALIZED_ACCEPT @@ -1147,6 +1206,8 @@ char *ap_default_mutex_method(void) t = "os2sem"; #elif defined USE_TPF_CORE_SERIALIZED_ACCEPT t = "tpfcore"; +#elif defined USE_BEOS_SERIALIZED_ACCEPT + t = "beos_sem"; #elif defined USE_NONE_SERIALIZED_ACCEPT t = "none"; #else @@ -1180,6 +1241,10 @@ char *ap_default_mutex_method(void) if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"tpfcore")))) return "tpfcore"; #endif +#if defined HAVE_BEOS_SERIALIZED_ACCEPT + if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"beos_sem")))) + return "beos_sem"; +#endif #if defined HAVE_NONE_SERIALIZED_ACCEPT if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"none")))) return "none"; @@ -1231,6 +1296,11 @@ char *ap_init_mutex_method(char *t) amutex = &accept_mutex_tpfcore_s; } else #endif +#if defined HAVE_BEOS_SERIALIZED_ACCEPT + if (!(strcasecmp(t,"beos_sem"))) { + amutex = &accept_mutex_beos_s; + } else +#endif #if defined HAVE_NONE_SERIALIZED_ACCEPT if (!(strcasecmp(t,"none"))) { amutex = &accept_mutex_none_s; @@ -3286,7 +3356,8 @@ static void detach(void) int x; chdir("/"); -#if !defined(MPE) && !defined(OS2) && !defined(TPF) +#if !defined(MPE) && !defined(OS2) && !defined(TPF) && !defined(BEOS) && \ + !defined(BONE) /* Don't detach for MPE because child processes can't survive the death of the parent. */ if ((x = fork()) > 0) @@ -3950,6 +4021,9 @@ static void show_compile_settings(void) #ifdef HAVE_TPF_CORE_SERIALIZED_ACCEPT printf(" -D HAVE_TPF_CORE_SERIALIZED_ACCEPT\n"); #endif +#ifdef HAVE_BEOS_SERIALIZED_ACCEPT + printf(" -D HAVE_BEOS_SERIALIZED_ACCEPT\n"); +#endif #ifdef HAVE_NONE_SERIALIZED_ACCEPT printf(" -D HAVE_NONE_SERIALIZED_ACCEPT\n"); #endif