Commit 0376baeb authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  *) Accomodate an out-of-space condition in the piped logs and the
     rotatelogs.c code, and no longer churn log processes for this
     condition.  [Victor J. Orlikowski]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87049 13f79535-47bb-0310-9956-ffa450edef68
parent 33d881b6
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -639,9 +639,8 @@ static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
	break;
    
    case APR_OC_REASON_UNWRITABLE:
	if (pl->pid != NULL) {
	    apr_kill(pl->pid, SIGTERM);
	}
        /* We should not kill off the pipe here, since it may only be full.
         * If it really is locked, we should kill it off manually. */
	break;
    
    case APR_OC_REASON_RESTART:
+49 −11
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@
#include <fcntl.h>

#define BUFSIZE         65536
#define ERRMSGSZ        82

#ifndef MAX_PATH
#define MAX_PATH        1024
@@ -79,11 +80,9 @@

int main (int argc, char *argv[])
{
    char buf[BUFSIZE], buf2[MAX_PATH];
    time_t tLogEnd = 0;
    time_t tRotation;
    int nLogFD = -1;
    int nRead;
    char buf[BUFSIZE], buf2[MAX_PATH], errbuf[ERRMSGSZ];
    time_t tLogEnd = 0, tRotation;
    int nLogFD = -1, nLogFDprev = -1, nMessCount = 0, nRead, nWrite;
    char *szLogRoot;

    if (argc != 3) {
@@ -123,7 +122,7 @@ int main (int argc, char *argv[])
            if (errno != EINTR)
                exit(4);
        if (nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0)) {
            close(nLogFD);
            nLogFDprev = nLogFD;
            nLogFD = -1;
        }
        if (nLogFD < 0) {
@@ -132,13 +131,52 @@ int main (int argc, char *argv[])
            tLogEnd = tLogStart + tRotation;
            nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666);
            if (nLogFD < 0) {
                /* 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 == -1) {
                    perror(buf2);
                    exit(2);
                }
                else {
                    nLogFD = nLogFDprev;
                    sprintf(errbuf,
                            "Resetting log file due to error opening "
                            "new log file. %10d messages lost.\n",
                            nMessCount);
                    nWrite = strlen(errbuf);
#ifdef WIN32
                    chsize(nLogFD, 0);
#else
                    ftruncate(nLogFD, 0);
#endif
                    write(nLogFD, errbuf, nWrite);
                }
        if (write(nLogFD, buf, nRead) != nRead) {
            perror(buf2);
            exit(5);
            }
            else {
                close(nLogFDprev);
            }
            nMessCount = 0;
        }
        do {
            nWrite = write(nLogFD, buf, nRead);
        } while (nWrite < 0 && errno == EINTR);
        if (nWrite != nRead) {
            nMessCount++;
            sprintf(errbuf,
                    "Error writing to log file. "
                    "%10d messages lost.\n",
                    nMessCount);
            nWrite = strlen(errbuf);
#ifdef WIN32
            chsize(nLogFD, 0);
#else
            ftruncate(nLogFD, 0);
#endif
            write (nLogFD, errbuf, nWrite);
        }
        else {
            nMessCount++;
        }
    }
    /* Of course we never, but prevent compiler warnings */