commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1040028 - in /commons/proper/daemon/trunk: RELEASE-NOTES.txt src/native/windows/apps/prunsrv/prunsrv.c
Date Mon, 29 Nov 2010 07:45:11 GMT
Author: mturk
Date: Mon Nov 29 07:45:11 2010
New Revision: 1040028

URL: http://svn.apache.org/viewvc?rev=1040028&view=rev
Log:
Fix DAEMON-188 by making sure the pidfile is destroyed on process exit

Modified:
    commons/proper/daemon/trunk/RELEASE-NOTES.txt
    commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c

Modified: commons/proper/daemon/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/RELEASE-NOTES.txt?rev=1040028&r1=1040027&r2=1040028&view=diff
==============================================================================
--- commons/proper/daemon/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/daemon/trunk/RELEASE-NOTES.txt Mon Nov 29 07:45:11 2010
@@ -70,7 +70,7 @@ NEW FEATURES:
 
 BUG FIXES:
 
-1.0.5:
+1.0.5: DAEMON-188
 
 1.0.4: DAEMON-95, DAEMON-171, DAEMON-100, DAEMON-164, DAEMON-165, DAEMON-175,
        DAEMON-177, DAEMON-150, DAEMON-163, DAEMON-182, DAEMON-181

Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c?rev=1040028&r1=1040027&r2=1040028&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c Mon Nov 29 07:45:11
2010
@@ -811,7 +811,7 @@ static int onExitHook(void)
 {
     apxLogWrite(APXLOG_MARK_DEBUG "On exit hook called ...");
     reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
-    return 0;    
+    return 0;
 }
 
 /* Executed when the service receives stop event */
@@ -1015,8 +1015,12 @@ static DWORD serviceStart()
         gPidfileName = apxLogFile(gPool, SO_LOGPATH, SO_PIDFILE, NULL, FALSE);
         if (GetFileAttributesW(gPidfileName) !=  INVALID_FILE_ATTRIBUTES) {
             /* Pid file exists */
-            apxLogWrite(APXLOG_MARK_ERROR "Pid file '%S' exists", gPidfileName);
-            return 1;
+            if (!DeleteFileW(gPidfileName)) {
+                /* Delete failed. Either no access or opened */
+                apxLogWrite(APXLOG_MARK_ERROR "Pid file '%S' exists",
+                            gPidfileName);
+                return 1;
+            }
         }
     }
     GetSystemTimeAsFileTime(&fts);
@@ -1123,7 +1127,8 @@ static DWORD serviceStart()
                                          FILE_SHARE_READ,
                                          NULL,
                                          CREATE_NEW,
-                                         FILE_ATTRIBUTE_NORMAL,
+                                         FILE_ATTRIBUTE_NORMAL |
+                                         FILE_FLAG_DELETE_ON_CLOSE,
                                          NULL);
 
             if (gPidfileHandle != INVALID_HANDLE_VALUE) {
@@ -1415,8 +1420,6 @@ BOOL docmdDebugService(LPAPXCMDLINE lpCm
     serviceMain(0, NULL);
     apxLogWrite(APXLOG_MARK_INFO "Debug service finished.");
     SAFE_CLOSE_HANDLE(gPidfileHandle);
-    if (gPidfileName)
-        DeleteFileW(gPidfileName);
     return rv;
 }
 
@@ -1432,8 +1435,6 @@ BOOL docmdRunService(LPAPXCMDLINE lpCmdl
     rv = (StartServiceCtrlDispatcherW(_service_table) != 0);
     apxLogWrite(APXLOG_MARK_INFO "Run service finished.");
     SAFE_CLOSE_HANDLE(gPidfileHandle);
-    if (gPidfileName)
-        DeleteFileW(gPidfileName);
     return rv;
 }
 



Mime
View raw message