You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2006/12/13 13:11:58 UTC

svn commit: r486612 - in /httpd/httpd/branches/2.2.x: CHANGES STATUS support/rotatelogs.c

Author: trawick
Date: Wed Dec 13 04:11:56 2006
New Revision: 486612

URL: http://svn.apache.org/viewvc?view=rev&rev=486612
Log:
merge from trunk: 

rotatelogs: Improve error message for open failures.

PR: 39487
Submitted by: jorton
Reviewed by: trawick, jim, wrowe

Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/support/rotatelogs.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?view=diff&rev=486612&r1=486611&r2=486612
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Wed Dec 13 04:11:56 2006
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+  *) rotatelogs: Improve error message for open failures.  PR 39487.
+     [Joe Orton]
+
   *) mod_dbd: share per-request database handles across subrequests
      and internal redirects [Chris Darroch]
 

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?view=diff&rev=486612&r1=486611&r2=486612
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Wed Dec 13 04:11:56 2006
@@ -89,15 +89,6 @@
       wrowe asks: isn't it time to make LogLevel directive parsing
                   reusable in the ap_config api?
 
-   * rotatelogs: Produce useful error messages for open() failures.
-     PR 39487
-     Trunk version of patch:
-       http://svn.apache.org/viewvc?view=rev&revision=478135
-       http://svn.apache.org/viewvc?view=rev&revision=485828
-     2.2.x version of patch:
-       Trunk version works.
-     +1: trawick, jim, wrowe
-
    * mod_proxy_balancer: Have the find_best_worker() function
     increment the elected counter, rather than requiring each
     ind lb method to do it, isolating what each lb method

Modified: httpd/httpd/branches/2.2.x/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/support/rotatelogs.c?view=diff&rev=486612&r1=486611&r2=486612
==============================================================================
--- httpd/httpd/branches/2.2.x/support/rotatelogs.c (original)
+++ httpd/httpd/branches/2.2.x/support/rotatelogs.c Wed Dec 13 04:11:56 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[120];
+
+                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) {