]> granicus.if.org Git - apache/commitdiff
Register for the SERVERDOWN event to allow Apache to shutdown gracefully
authorBradley Nicholes <bnicholes@apache.org>
Thu, 12 Dec 2002 19:40:52 +0000 (19:40 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Thu, 12 Dec 2002 19:40:52 +0000 (19:40 +0000)
when the NetWare OS is shutdown

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97898 13f79535-47bb-0310-9956-ffa450edef68

os/netware/util_nw.c
server/mpm/netware/mpm_netware.c

index 005b1a95cc817fc07de196aa6399a00a6942aa66..a9a411885d96c8f429724e00137030b28cbc7616 100644 (file)
 #include "http_log.h"
 
 #include <netware.h>
+#include <nks\netware.h>
 
-int nlmUnloadSignaled();
+int nlmUnloadSignaled(int wait);
+event_handle_t eh;
+Warn_t ref;
 
 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
     const request_rec *r,
@@ -75,5 +78,61 @@ AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
 
 int  _NonAppCheckUnload( void )
 {
-       return nlmUnloadSignaled();
+       return nlmUnloadSignaled(1);
 }
+
+// down server event callback
+void ap_down_server_cb(void *, void *)
+{
+       nlmUnloadSignaled(0);
+    return;
+}
+
+// destroy callback resources
+void ap_cb_destroy(void *)
+{
+  // cleanup down event notification
+  UnRegisterEventNotification(eh);
+  NX_UNWRAP_INTERFACE(ref);
+}
+
+int _NonAppStart
+(
+    void        *NLMHandle,
+    void        *errorScreen,
+    const char  *cmdLine,
+    const char  *loadDirPath,
+    size_t      uninitializedDataLength,
+    void        *NLMFileHandle,
+    int         (*readRoutineP)( int conn, void *fileHandle, size_t offset,
+                    size_t nbytes, size_t *bytesRead, void *buffer ),
+    size_t      customDataOffset,
+    size_t      customDataSize,
+    int         messageCount,
+    const char  **messages
+)
+{
+#pragma unused(cmdLine)
+#pragma unused(loadDirPath)
+#pragma unused(uninitializedDataLength)
+#pragma unused(NLMFileHandle)
+#pragma unused(readRoutineP)
+#pragma unused(customDataOffset)
+#pragma unused(customDataSize)
+#pragma unused(messageCount)
+#pragma unused(messages)
+
+    // register for down server event
+    rtag_t rt = AllocateResourceTag(NLMHandle, "Apache2 Down Server Callback",
+                                    EventSignature);
+
+    NX_WRAP_INTERFACE((void *)ap_down_server_cb, 2, (void **)&ref);
+    eh = RegisterForEventNotification(rt, EVENT_DOWN_SERVER,
+                                      EVENT_PRIORITY_APPLICATION,
+                                      ref, NULL, NULL);
+
+    // clean-up
+    NXVmRegisterExitHandler(ap_cb_destroy, NULL);
+
+}
+
index 658c4af1b9df0d73ae6eb53cbf95dd9fa148cafa..18d79944138b046428a54139876b1849b9df5c9f 100644 (file)
@@ -318,12 +318,14 @@ static void set_signals(void)
     apr_signal(SIGABRT, sig_term);
 }
 
-int nlmUnloadSignaled()
+int nlmUnloadSignaled(int wait)
 {
     shutdown_pending = 1;
 
-    while (wait_to_finish) {
-        NXThreadYield();
+    if (wait) {
+        while (wait_to_finish) {
+            NXThreadYield();
+        }
     }
 
     return 0;