[Greylist-users] is alarm() thread-safe?

Fletcher Mattox fletcher at cs.utexas.edu
Thu Jun 24 22:37:07 PDT 2004


Someone recently suggested auto whitelisting peers which have a server
listening on port 25.  This seemed like a good idea to me, so I wrote
some code to do it.  In envrcpt_callback(), I have something like this:

  my $ret = 0;
  eval {
    alarm 1;
    $ret = &connect_to_server($server);		# does a connect()
    alarm 0;

and I have set a handler in the startup code like this:

  $SIG{ALRM} = sub { die "timeout" };

This mostly works, but perl occasionally segfaults in the signal handler
called from libthread.  Does this mean alarm() is not thread-safe?
If so, how can I timeout the connect() to my smtp peer?

I'm using perl 5.8.4 with sendmail 8.13.0 on Solaris 9.


More information about the Greylist-users mailing list