httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r478135 - /httpd/httpd/trunk/support/rotatelogs.c
Date Wed, 22 Nov 2006 11:48:55 GMT
Author: jorton
Date: Wed Nov 22 03:48:55 2006
New Revision: 478135

URL: http://svn.apache.org/viewvc?view=rev&rev=478135
Log:
* support/rotatelogs.c (main): Produce useful error message for open()
failures.

PR: 39487

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

Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?view=diff&rev=478135&r1=478134&r2=478135
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Wed Nov 22 03:48:55 2006
@@ -54,7 +54,7 @@
 #endif
 
 #define BUFSIZE         65536
-#define ERRMSGSZ        82
+#define ERRMSGSZ        128
 
 #ifndef MAX_PATH
 #define MAX_PATH        1024
@@ -188,6 +188,7 @@
 
         if (nLogFD == NULL) {
             int tLogStart;
+            apr_status_t rv;
 
             if (tRotation) {
                 tLogStart = (now / tRotation) * tRotation;
@@ -208,22 +209,28 @@
                 sprintf(buf2, "%s.%010d", szLogRoot, tLogStart);
             }
             tLogEnd = tLogStart + tRotation;
-            apr_file_open(&nLogFD, buf2, APR_READ | APR_WRITE | APR_CREATE | APR_APPEND,
-                          APR_OS_DEFAULT, pool);
-            if (nLogFD == NULL) {
+            rv = apr_file_open(&nLogFD, buf2, APR_WRITE | APR_CREATE | APR_APPEND,
+                               APR_OS_DEFAULT, pool);
+            if (rv != APR_SUCCESS) {
+                char error[26];
+
+                apr_strerror(rv, error, sizeof error);
+
                 /* Uh-oh. Failed to open the new log file. Try to clear
                  * the previous log file, note the lost log entries,
                  * and keep on truckin'. */
                 if (nLogFDprev == NULL) {
-                    fprintf(stderr, "1 Previous file handle doesn't exists %s\n", buf2);
+                    fprintf(stderr, "Could not open log file '%s' (%s)\n", buf2, error);
                     exit(2);
                 }
                 else {
                     nLogFD = nLogFDprev;
-                    sprintf(errbuf,
-                            "Resetting log file due to error opening "
-                            "new log file. %10d messages lost.\n",
-                            nMessCount);
+                    /* Try to keep this error message constant length
+                     * in case it occurs several times. */
+                    apr_snprintf(errbuf, sizeof errbuf,
+                                 "Resetting log file due to error opening "
+                                 "new log file, %10d messages lost: %-25.25s\n",
+                                 nMessCount, error);
                     nWrite = strlen(errbuf);
                     apr_file_trunc(nLogFD, 0);
                     if (apr_file_write(nLogFD, errbuf, &nWrite) != APR_SUCCESS) {



Mime
View raw message