http://bugzilla.spamassassin.org/show_bug.cgi?id=3828





------- Additional Comments From [EMAIL PROTECTED]  2004-11-24 10:05 -------
Subject: Re:  [review] spamd parent stops accepting requests 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> okay, but we still run into a similar deal here.  the alarm that
> encompasses check() in spamd is what we would want to store as
> $oldalarm.   and in order to restore $oldalarm we would have to get it
> passed into PerMsgStatus, since $oldalarm would be set per-child,
> per-check.  

No -- it doesn't need to be passed anywhere.   The key point: the alarm
doco indicates that when you call alarm() again, it'll tell you how much
time is left -- so *that value* can be used to reinstate the alarm again.
no other var is necessary.

I'll go into more detail with some code snippets.

in accept_a_conn():

     eval {
       $SIG{'ALRM'} = sub { die (" child processing timeout ") };
       alarm $timeout_child if ($timeout_child);
       check( $1, $2, $start, $remote_hostname, $remote_hostaddr );
     };
     alarm 0;

(same as normal).
in dcc_lookup(), and other fns that use alarm() themselves:

+ my $oldalarm;
  eval {
    local $SIG{ALRM} = sub { die "__alarm__\n" };
    local $SIG{PIPE} = sub { die "__brokenpipe__\n" };

+   $oldalarm = alarm($timeout);

    # Note: not really tainted, these both come from system conf file.
    my $path = Mail::SpamAssassin::Util::untaint_file_path 
($self->{conf}->{dcc_path});
    [... dcc checking]

    dbg("dcc: got response: $response");

+   alarm $oldalarm;
    $self->cleanup_kids($pid);
  };

+ alarm $oldalarm;


so IOW the setting of $timeout_child doesn't have go beyond spamd; the
alarm() API allows us to take care of it everywhere else, because alarm()
itself will return the details we need.

Note that if no alarm is already set, ie. if timeout-child wasn't used,
"$oldalarm = alarm($timeout);" will still do the right thing as $oldalarm
will be 0.



anyway, just to deal with the other q's:

> 'actually, no, it's fine to do that -- each M:SA object is
> single-threaded.' 
> 
> but the spamd daemon only creates one instance of M::SA->new(), so
> storing start_time or $oldalarm or anything would not be child
> (per-check) specific, since M::SA->new() is not called per
> accept_a_conn().   or maybe i'm missing something here?   The only
> things i see called per-check is M::SA::Message->new() and
> M::SA::PerMsgStatus->new(), so start_time or $oldalarm would need to be
> passed in there somehow to have access to it.

you can just add a var on the M:Sa object before
check() starts --

    $spamtest->{some_var} = "blah";

M:Sa objects are just hashes.

> or i guess instead of alarming spamd with timeout_child, it could be
> moved down to M::SA::check() instead.   This would help people that dont
> use spamd take advantage of running command line spamassassin with a
> --timeout-child also.

I think the spamd alarm is cleaner. see above.

- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFBpM0aMJF5cimLx9ARAsKHAJ0a6Ae7EtZmmseAXVsihztgCPOmxQCgrBuy
va6EKlAixASEUXQ8/9IdpOQ=
=qwXu
-----END PGP SIGNATURE-----





------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Reply via email to