Hi Matthew,
On Tue, 31 Jul 2007 07:13:37 -0400
Matthew Harrell <[EMAIL PROTECTED]> wrote:
> : Depending on which flavour of qpsmtpd you're running, this (register())
> : is probably not be the right place for opening connections. The connection
> : would be shared by all sub processes of qpsmtpd and is likely to trash
> : the data. The connect hook is guaranteed to happen after any fork()s.
> The forks occur when an smtp connect happens, right? I was envisioning
Uhm... for -forkserver, yes.
In -prefork (as the name implies) it's forked before any connections
are accepted, these forked instances are reused... but: not all of
$max_children instances are forked on startup.
The -async forks (if the --procs argument is > 1) at startup.
Not sure what's with Apache::Qpsmtpd, IIRC the plugins are loaded on
the first connect of a client and then reused.
You're on the save side if you open the DB connection in the connect
hook (not pre_connection, that may run before a fork).
> having the rrd class opened in the register, written to by each fork when
> it gets to the hook_queue_pre / hook_deny phase (protected by a flock),
> and then the whole thing closed down when qpsmtpd shuts down. In the case
Hmm, the disconnect hook should be run any time a client disconnects
(on "QUIT", connection timeout or a DENY*_DISCONNECT). Isn't that the
right place for you to open the connection, lock the DB and write all
data?
> I'm working with the shutdown isn't a big deal since the rrd connection
> itself is done through a pipe but the shutdown method would be nice to
> sync out remaining data in the queue.
What happens if two or more processes write to the opened (during
register()) pipe at the same time (seen from the pipe's end all data
arrives on the same FD)?
How how do other processes know which process locked the file^Wpipe
(and how to lock an unnamed pipe, or are you using a FIFO)?
Hanno