Author: mturk
Date: Tue Feb  5 16:28:35 2013
New Revision: 1442650

URL: http://svn.apache.org/viewvc?rev=1442650&view=rev
Log:
DAEMON-276 Fix log file corruption

Modified:
    
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.h
    
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.rc
    
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.h
    
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.rc
    commons/proper/daemon/branches/1.0.x/src/native/windows/include/log.h
    commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c

Modified: 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.h
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.h?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.h 
(original)
+++ 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.h 
Tue Feb  5 16:28:35 2013
@@ -24,7 +24,7 @@
 #define _PRUNMGR_H
 
 #undef  PRG_VERSION
-#define PRG_VERSION    "1.0.12.0"
+#define PRG_VERSION    "1.0.13.0"
 #define PRG_REGROOT   L"Apache Software Foundation\\Procrun 2.0"
 
 #define IDM_TM_EXIT                     2000

Modified: 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.rc
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.rc?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.rc 
(original)
+++ 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunmgr/prunmgr.rc 
Tue Feb  5 16:28:35 2013
@@ -228,7 +228,7 @@ END
 STRINGTABLE
 BEGIN
     IDS_APPLICATION     RSTR_PSM
-    IDS_APPVERSION      "Version 1.0.12"
+    IDS_APPVERSION      "Version 1.0.13"
     IDS_APPFULLNAME     RSTR_PSM " Version " PRG_VERSION
     IDS_APPCOPYRIGHT    "Copyright (c) 2000-2013 The Apache Software 
Foundation"
     IDS_APPDESCRIPTION  "Apache Commons Daemon Service Management Tool"
@@ -259,8 +259,8 @@ BEGIN
 END
 
 1 VERSIONINFO
- FILEVERSION 1,0,12,0
- PRODUCTVERSION 1,0,12,0
+ FILEVERSION 1,0,13,0
+ PRODUCTVERSION 1,0,13,0
  FILEFLAGSMASK 0x3fL
 #if defined(_DEBUG)
  FILEFLAGS 0x03L

Modified: 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.h
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.h?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.h 
(original)
+++ 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.h 
Tue Feb  5 16:28:35 2013
@@ -25,7 +25,7 @@
 #define _PRUNSRV_H
 
 #undef  PRG_VERSION
-#define PRG_VERSION    "1.0.12.0"
+#define PRG_VERSION    "1.0.13.0"
 #define PRG_REGROOT   L"Apache Software Foundation\\Procrun 2.0"
 
 #endif /* _PRUNSRV_H */

Modified: 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.rc
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.rc?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.rc 
(original)
+++ 
commons/proper/daemon/branches/1.0.x/src/native/windows/apps/prunsrv/prunsrv.rc 
Tue Feb  5 16:28:35 2013
@@ -23,8 +23,8 @@ IDI_MAINICON         ICON               
 CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "prunsrv.manifest"
 
 1 VERSIONINFO
- FILEVERSION 1,0,12,0
- PRODUCTVERSION 1,0,12,0
+ FILEVERSION 1,0,13,0
+ PRODUCTVERSION 1,0,13,0
  FILEFLAGSMASK 0x3fL
 #if defined(_DEBUG)
  FILEFLAGS 0x03L

Modified: commons/proper/daemon/branches/1.0.x/src/native/windows/include/log.h
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/include/log.h?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/windows/include/log.h 
(original)
+++ commons/proper/daemon/branches/1.0.x/src/native/windows/include/log.h Tue 
Feb  5 16:28:35 2013
@@ -38,6 +38,16 @@ __APXBEGIN_DECLS
         UnlockFile(file, 0, 0, 512, 0);             \
     APXMACRO_END
 
+#define APX_LOGENTER()                              \
+    if (_pt_sys_loglock)                            \
+        EnterCriticalSection(_pt_sys_loglock);      \
+    else (void)0
+
+#define APX_LOGLEAVE()                              \
+    if (_pt_sys_loglock)                            \
+        LeaveCriticalSection(_pt_sys_loglock);      \
+    else (void)0
+
 #define APXLOG_LEVEL_DEBUG  0
 #define APXLOG_LEVEL_INFO   1
 #define APXLOG_LEVEL_WARN   2

Modified: commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c
URL: 
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c?rev=1442650&r1=1442649&r2=1442650&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c Tue Feb  
5 16:28:35 2013
@@ -41,9 +41,10 @@ typedef struct apx_logfile_st {
 } apx_logfile_st;
 
 /* Per-application master log file */
-static apx_logfile_st *_st_sys_loghandle = NULL;
-
-static apx_logfile_st  _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE};
+static apx_logfile_st   *_st_sys_loghandle = NULL;
+static CRITICAL_SECTION  _st_sys_loglock;
+static CRITICAL_SECTION *_pt_sys_loglock = NULL;
+static apx_logfile_st    _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE};
 
 static void logRotate(apx_logfile_st *lf, LPSYSTEMTIME t)
 {
@@ -171,6 +172,10 @@ HANDLE apxLogOpen(
     SYSTEMTIME sysTime;
     apx_logfile_st *h;
 
+    if (_pt_sys_loglock == NULL) {
+        InitializeCriticalSection(&_st_sys_loglock);
+        _pt_sys_loglock = &_st_sys_loglock;
+    }
     GetLocalTime(&sysTime);
     if (!szPath) {
         if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
@@ -304,6 +309,7 @@ apxLogWrite(
     }
     if (dwLevel < lf->dwLogLevel)
         return 0;
+    APX_LOGENTER();
     if (f && (lf->dwLogLevel == APXLOG_LEVEL_DEBUG || dwLevel == 
APXLOG_LEVEL_ERROR)) {
         f = (szFile + lstrlenA(szFile) - 1);
         while(f != szFile && '\\' != *f && '/' != *f)
@@ -389,6 +395,7 @@ apxLogWrite(
         }
 #endif
     }
+    APX_LOGLEAVE();
     /* Restore the last Error code */
     SetLastError(err);
     if (szFormat && err != 0 && dwLevel == APXLOG_LEVEL_ERROR) {


Reply via email to