From nobody@hyperreal.com Fri Sep 27 17:48:51 1996 Received: by taz.hyperreal.com (8.7.5/V2.0) id RAA25104; Fri, 27 Sep 1996 17:48:51 -0700 (PDT) Message-Id: <199609280048.RAA25104@taz.hyperreal.com> Date: Fri, 27 Sep 1996 17:48:51 -0700 (PDT) From: Mark Brown Reply-To: mbrown@openmarket.com To: apbugs@hyperreal.com Subject: error log problems, fix included X-Send-Pr-Version: 3.2 >Number: 4 >Category: other >Synopsis: error log problems, fix included >Confidential: no >Severity: critical >Priority: medium >Responsible: apache >State: closed >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Fri Sep 27 17:49:02 1996 >Last-Modified: Mon Oct 7 23:39:57 PDT 1996 >Originator: mbrown@openmarket.com >Organization: >Release: 1.1.1 >Environment: Sunos 4.1.4 >Description: On some unixes, fopen(path, "a") seeks to the end-of-file rather than opening the file in O_APPEND mode. SunOS seems to have this affliction. This doesn't work if another process opens the same file for append, as opposed to sharing the file descriptor. Because mod_fastcgi starts its process manager process from a module init proc, and the error log isn't open at the time that module init procs are called, mod_fastcgi is being bitten by this problem. Either the error log should be opened before the module init procs are called, or pfopen should work around the problem by doing the correct open (with O_APPEND) and then calling fdopen. >How-To-Repeat: >Fix: % diff -c alloc.c alloc.c.orig *** alloc.c Mon Sep 23 17:45:34 1996 --- alloc.c.orig Mon Sep 23 17:43:16 1996 *************** *** 765,784 **** FILE *pfopen(struct pool *a, char *name, char *mode) { ! FILE *fd = NULL; block_alarms(); ! if (*mode == 'a') { ! /* Work around faulty implementations of fopen */ ! int baseFlag = (*(mode+1) == '+') ? O_RDWR : O_WRONLY; ! int desc = open(name, baseFlag | O_APPEND | O_CREAT, ! S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); ! if (desc >= 0) { ! fd = fdopen(desc, mode); ! } ! } else { ! fd = fopen(name, mode); ! } if (fd != NULL) note_cleanups_for_file (a, fd); unblock_alarms(); return fd; --- 765,774 ---- FILE *pfopen(struct pool *a, char *name, char *mode) { ! FILE *fd; block_alarms(); ! fd = fopen(name, mode); if (fd != NULL) note_cleanups_for_file (a, fd); unblock_alarms(); return fd; %0 >Audit-Trail: State-Changed-From-To: open-closed State-Changed-By: brian State-Changed-When: Mon Oct 7 23:39:56 PDT 1996 State-Changed-Why: Patch applied to CVS tree for 1.2-dev. >Unformatted: