You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Havard <br...@kheldar.apana.org.au> on 1998/07/20 07:44:57 UTC
[PATCH] OS/2 serialized accepts
It's been brought to my attention that Apache on OS/2 doesn't serialize
accepts so gives nasty warnings if you use multiple Listen directives.
This patch implements serialized accepts using OS/2's native mutex semaphores.
Index: include/ap_config.h
===================================================================
RCS file: /cvs/apache-1.3/src/include/ap_config.h,v
retrieving revision 1.227
diff -u -w -r1.227 ap_config.h
--- ap_config.h 1998/07/18 15:30:43 1.227
+++ ap_config.h 1998/07/20 04:45:22
@@ -671,6 +671,7 @@
#define MAXSOCKETS 4096
#define USE_OS2_SCOREBOARD
#define NO_RELIABLE_PIPED_LOGS
+#define USE_OS2SEM_SERIALIZED_ACCEPT
#elif defined(__MACHTEN__)
typedef int rlim_t;
Index: main/http_main.c
===================================================================
RCS file: /cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.374
diff -u -w -r1.374 http_main.c
--- http_main.c 1998/07/14 09:57:56 1.374
+++ http_main.c 1998/07/20 04:46:31
@@ -190,6 +190,7 @@
/* Add MMAP style functionality to OS/2 */
#define INCL_DOSMEMMGR
#define INCL_DOSEXCEPTIONS
+#define INCL_DOSSEMAPHORES
#include <os2.h>
#include <umalloc.h>
#include <stdio.h>
@@ -834,6 +835,69 @@
if (flock(lock_fd, LOCK_UN) < 0) {
ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
"flock: LOCK_UN: Error freeing accept lock. Exiting!");
+ clean_child_exit(APEXIT_CHILDFATAL);
+ }
+}
+
+#elif defined(USE_OS2SEM_SERIALIZED_ACCEPT)
+
+static HMTX lock_sem = -1;
+
+static void accept_mutex_cleanup(void *foo)
+{
+ DosCloseMutexSem(lock_sem);
+}
+
+/*
+ * Initialize mutex lock.
+ * Done by each child at it's birth
+ */
+static void accept_mutex_child_init(pool *p)
+{
+ int rc = DosOpenMutexSem(NULL, &lock_sem);
+
+ if (rc != 0) {
+ ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ "Child cannot open lock semaphore");
+ clean_child_exit(APEXIT_CHILDINIT);
+ }
+}
+
+/*
+ * Initialize mutex lock.
+ * Must be safe to call this on a restart.
+ */
+static void accept_mutex_init(pool *p)
+{
+ int rc = DosCreateMutexSem(NULL, &lock_sem, DC_SEM_SHARED, FALSE);
+
+ if (rc != 0) {
+ ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ "Parent cannot create lock semaphore");
+ exit(APEXIT_INIT);
+ }
+
+ ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
+}
+
+static void accept_mutex_on(void)
+{
+ int rc = DosRequestMutexSem(lock_sem, SEM_INDEFINITE_WAIT);
+
+ if (rc != 0) {
+ ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ "OS2SEM: Error %d getting accept lock. Exiting!", rc);
+ clean_child_exit(APEXIT_CHILDFATAL);
+ }
+}
+
+static void accept_mutex_off(void)
+{
+ int rc = DosReleaseMutexSem(lock_sem);
+
+ if (rc != 0) {
+ ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ "OS2SEM: Error %d freeing accept lock. Exiting!", rc);
clean_child_exit(APEXIT_CHILDFATAL);
}
}
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------