[Mimedefang] file descriptor scope and embedded perl
Chris Masters
rotis23 at yahoo.com
Tue Jul 6 09:25:00 EDT 2004
Thanks for your replies.
I still have the problem of bad file descriptors:
I *declare* my db handles in filter_initialize:
sub filter_initialize()
{
#Declare Connection handles
undef $My_dbh;
}
I obtain a valid open db handle using a function
get_db_connection (as per David's suggestion a long
while ago - thanks BTW):
sub get_db_connection()
{
if (defined($My_dbh) && test_query($My_dbh))
{
return $My_dbh;
}
undef $My_dbh;
$My_dbh = connect_db();
return $My_dbh;
}
This is called within filter_begin, filter and
filter_end.
I'm getting test_query failures dotted around the logs
- luckily the database connection is then
re-established :)
There is now no db
declaration/initialisation/query/code outside of any
filter function and as such all should take place
after the fork(2).
Where am I going wrong?
Cheers, Chrsi
--- "David F. Skoll" <dfs at roaringpenguin.com> wrote:
> On Mon, 5 Jul 2004, Chris Masters wrote:
>
> > Since upgrading to the latest MIMEDefang today I
> have
> > bad file descriptor errors - I assume this is an
> > embedded perl scope issue.
>
> Possibly.
>
> > 1) I do *not* use filer_initialise
>
> You should probably use it. Any files opened at
> global scope outside
> any function are opened once upon initialization.
> When a slave is
> started, mimedefang-multiplexor calls fork(2) and
> essentially dup's
> the file descriptors. However, the multiplexor
> child process (the one
> that's about to morph into a slave) then calls
> close(2) on all open
> file descriptors. Perl doesn't know about this---it
> thinks the file
> descriptors are still open---so when you try to use
> them, you get
> error messages.
>
> > Can/Should I declare *slave* globals in
> > filter_initialise?
>
> Yes. (And it's ...ize rather than ...ise, because
> I'm in North America
> rather than the UK. :-))
>
> Regards,
>
> David.
> _______________________________________________
> Visit http://www.mimedefang.org and
> http://www.canit.ca
> MIMEDefang mailing list
> MIMEDefang at lists.roaringpenguin.com
>
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
More information about the MIMEDefang
mailing list