On Mon, Jun 05, 2006 at 11:04:42AM -0700, Debian Bug Tracking System wrote: > This is an automatic notification regarding your Bug report > #90260: uptimed keeps forgetting uptimes, > which was filed against the uptimed package. > > It has been closed by Thibaut VARENE <[EMAIL PROTECTED]>. > > Their explanation is attached below. If this explanation is > unsatisfactory and you have not received a better one in a separate > message then please contact Thibaut VARENE <[EMAIL PROTECTED]> by replying > to this email. > > Debian bug tracking system administrator > (administrator, Debian Bugs database) >
> Date: Mon, 5 Jun 2006 19:34:55 +0200 > From: Thibaut VARENE <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: too old > Organization: Debian > X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 > (1.212-2003-09-23-exp) on spohr.debian.org > X-Spam-Level: > X-Spam-Status: No, hits=-2.0 required=4.0 tests=BAYES_00,RCVD_IN_SORBS > autolearn=no version=2.60-bugs.debian.org_2005_01_02 > > closing this bug as it probably no longer exists > > T-Bone Nope, the bug is still there. The function save_records needs to check ferror(f) after fflush(f) (which is missing) and before fclose(f). If ferror() returns true then it must not rename the (damaged) temporary file over the (good) existing file. Sort of like this: --- ./libuptimed/urec.c.orig 2006-06-05 16:34:08.000000000 -0400 +++ ./libuptimed/urec.c 2006-06-05 16:39:19.000000000 -0400 @@ -245,6 +245,7 @@ FILE *f; Urec *u; int i=0; + int err; f=fopen(FILE_RECORDS".tmp", "w"); if (!f) @@ -264,8 +265,18 @@ break; } } + /* Push buffers out to filesystem */ + fflush(f); + /* Check error status on stream just before closing */ + err=ferror(f); fclose(f); - rename(FILE_RECORDS".tmp", FILE_RECORDS); + /* Don't keep the temporary file if there was an error while writing it */ + if (ferror(f)) { + printf("uptimed: error while writing to %s\n", FILE_RECORDS".tmp"); + unlink(FILE_RECORDS".tmp"); + } else { + rename(FILE_RECORDS".tmp", FILE_RECORDS); + } } #ifdef PLATFORM_LINUX
signature.asc
Description: Digital signature