1 Date: Sat, 5 Jan 2002 21:46:44 -0800
2 From: Kamal A Mostafa <kamal@whence.com>
3 To: Riccardo Facchetti <riccardo@master.oasi.gpa.it>, Kern Sibbald <kern@sibbald.com>
4 Subject: new EVENTSFILEMAX code
8 Well, I went ahead and rewrote truncate_events_file() from scratch -- it was
9 a nice file-size-based thing that used no malloc's. Alas, while testing it I
10 discovered a rather nasty bug which, I believe, has been present since at
13 I was running some tests where I'd fill up the events file to force the new
14 truncation code to kick in. The new code worked fine, but when I killed
15 off apcupsd, I noticed that I didn't get the usual "apcupsd exiting, signal
16 15" and "apcupsd shutdown succeeded" log_event() messages that should have
17 been at the tail end of the eventsfile.
19 I suspect that the function terminate() is using an old copy of the event_fd
20 file descriptor (which has since been closed) or something along those lines.
21 As I see it, any truncation scheme which closes and reopens the ups->evend_fd
22 would cause this problem. Maybe truncation screws up the forked children or
25 So I rewrote it again. My new trim_eventfile() doesn't ever close the
26 ups->event_fd -- that's probably just "better" anyway. The basic premise is
27 rewind, read, rewind, truncate, write. And sure enough, now I get the
28 "exiting" messages even after the file has been trimmed, so I think all is
31 *Whew* I'm sorry I ever started poking at it in the first place! ;-}
34 Anyway... The new version replaces the TRIMEVENTSFILE [on|off] param with
35 "EVENTSFILEMAX <kilobytes>". I've attached two versions of the patch. Use
36 one or the other, depending on whether you have or haven't already applied
37 my previous TRIMEVENTSFILE patch.
39 apc.evmax-398.patch -applies to apcupsd-3.9.8-18Dec01
41 apc.evmax-kamal.patch -applies to TRIMEVENTSFILE version
47 KES: Integrated 9Jan02 there were a number of rejects due to space/tab