UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / doc / techlogs / 2002 / kam05Jan02
blobb3b90cda1852d353fa48809092d823bae621b5a8
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
6 Hi Guys-
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
11 least 3.8.4...
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
23 threads also.  Bummer.
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
29 well.
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
43 Comments?
45 ===================
47 KES: Integrated 9Jan02 there were a number of rejects due to space/tab
48      mangling.