[Mimedefang] Timeout on md_check_against_smtp_server?

Dianne Skoll dfs at roaringpenguin.com
Sat Aug 15 10:42:35 EDT 2015


On Sat, 15 Aug 2015 12:39:04 +0100
Dave Osbourne <dave at osbourne.uk.eu.org> wrote:

> I wonder if there is away to enforce a timeout on 
> md_check_against_smtp_server?

The general-purpose way of enforcing timeouts is with alarm.

{
    local $SIG{ALRM} = sub { die "Timeout"; };
    my @result;
    eval {
    	 alarm(60); # Or whatever timeout you want
	 @result = md_check_against_smtp_server(...);
	 alarm(0);
    };
    if ($@ && $@ =~ /Timeout/) {
        # Handle timeout
    } else {
        # Handle @result
    }
}

Regards,

Dianne.



More information about the MIMEDefang mailing list