You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2013/03/11 07:57:31 UTC

svn commit: r1455019 - /commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c

Author: mturk
Date: Mon Mar 11 06:57:31 2013
New Revision: 1455019

URL: http://svn.apache.org/r1455019
Log:
Make sure we unlock the rotated file before closing so that it does not depend on OS unlocking which can take some time

Modified:
    commons/proper/daemon/branches/1.0.x/src/native/windows/src/log.c

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=1455019&r1=1455018&r2=1455019&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 Mon Mar 11 06:57:31 2013
@@ -89,6 +89,10 @@ static void logRotate(apx_logfile_st *lf
         /* TODO: Log something */
         return;
     }
+    /* Make sure we relock the correct file */
+    APX_LOGLOCK(h);
+    APX_LOGUNLOCK(lf->hFile);
+    /* Close original handle */
     CloseHandle(lf->hFile);
     lf->hFile = h;
 }
@@ -305,6 +309,9 @@ apxLogWrite(
     if (IS_INVALID_HANDLE(lf)) {
         lf = &_st_sys_errhandle;
         lf->hFile = GetStdHandle(STD_ERROR_HANDLE);
+    }
+    if (lf == &_st_sys_errhandle) {
+        /* Do not rotate if redirected to console */
         dolock = FALSE;
     }
     if (dwLevel < lf->dwLogLevel)