]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add the serialization stuff for BeOS to get us building again.
authorDavid Reid <dreid@apache.org>
Fri, 16 Nov 2001 01:32:20 +0000 (01:32 +0000)
committerDavid Reid <dreid@apache.org>
Fri, 16 Nov 2001 01:32:20 +0000 (01:32 +0000)
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

src/include/ap_config.h
src/main/http_core.c
src/main/http_main.c

index d63e52887b83d6946a7d2957766f8d45b15b4e47..daeccae76570da8a265b261148bb060490e93ff0 100644 (file)
@@ -895,6 +895,10 @@ typedef int rlim_t;
 #undef PLATFORM
 #define PLATFORM "BeOS"
 #include <stddef.h>
+#include <kernel/OS.h>
+
+#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 <kernel/OS.h>
+
 #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
index a5ba80ecbe8609e9144fdb8e0e01b764f1903e01..3072b194b0ecbb47d6b92ce55b65e53dfb7fb8c5 100644 (file)
@@ -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
index 425e2d88d2969fc8f4a13818f049db0d5b383504..3d859b08ff34da18b0506637e72e8a8bfc0ac6bd 100644 (file)
@@ -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