httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r646845 - in /httpd/httpd/trunk: CHANGES support/rotatelogs.c
Date Thu, 10 Apr 2008 15:33:10 GMT
Author: trawick
Date: Thu Apr 10 08:33:05 2008
New Revision: 646845

URL: http://svn.apache.org/viewvc?rev=646845&view=rev
Log:
rotatelogs: Log the current file size and error code/description
when failing to write to the log file. 

Sometimes users have a hard time believing that their little log
file was really big enough to reach quota/filesystem/other limit
back at the time of the error.


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/support/rotatelogs.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=646845&r1=646844&r2=646845&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Apr 10 08:33:05 2008
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) rotatelogs: Log the current file size and error code/description
+     when failing to write to the log file.  [Jeff Trawick]
+
   *) mod_dbd: Handle integer configuration directive parameters with a
      dedicated function.
 

Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=646845&r1=646844&r2=646845&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Thu Apr 10 08:33:05 2008
@@ -58,7 +58,7 @@
 #endif
 
 #define BUFSIZE         65536
-#define ERRMSGSZ        128
+#define ERRMSGSZ        256
 
 #ifndef MAX_PATH
 #define MAX_PATH        1024
@@ -299,13 +299,32 @@
          */
         if (!bypass_io) {
             nWrite = nRead;
-            apr_file_write(nLogFD, buf, &nWrite);
+            rv = apr_file_write(nLogFD, buf, &nWrite);
+            if (rv == APR_SUCCESS && nWrite != nRead) {
+                /* buffer partially written, which for rotatelogs means we encountered
+                 * an error such as out of space or quota or some other limit reached;
+                 * try to write the rest so we get the real error code
+                 */
+                apr_size_t nWritten = nWrite;
+
+                nRead  = nRead - nWritten;
+                nWrite = nRead;
+                rv = apr_file_write(nLogFD, buf + nWritten, &nWrite);
+            }
             if (nWrite != nRead) {
+                char strerrbuf[120];
+                apr_off_t cur_offset;
+                
+                cur_offset = 0;
+                if (apr_file_seek(nLogFD, APR_CUR, &cur_offset) != APR_SUCCESS) {
+                    cur_offset = -1;
+                }
+                apr_strerror(rv, strerrbuf, sizeof strerrbuf);
                 nMessCount++;
-                sprintf(errbuf,
-                        "Error writing to log file. "
-                        "%10d messages lost.\n",
-                        nMessCount);
+                apr_snprintf(errbuf, sizeof errbuf,
+                             "Error %d writing to log file at offset %" APR_OFF_T_FMT ".
"
+                             "%10d messages lost (%s)\n",
+                             rv, cur_offset, nMessCount, strerrbuf);
                 nWrite = strlen(errbuf);
                 apr_file_trunc(nLogFD, 0);
                 if (apr_file_write(nLogFD, errbuf, &nWrite) != APR_SUCCESS) {



Mime
View raw message