From 31a498cfd75c6d11c0d1c4d6ad6751a9d60b3c7b Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Thu, 13 Mar 2008 21:20:56 +0000 Subject: [PATCH] Restore timers on reset git-svn-id: https://svn.perl.org/qpsmtpd/trunk@859 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Danga/TimeoutSocket.pm | 5 +++++ qpsmtpd-async | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Danga/TimeoutSocket.pm b/lib/Danga/TimeoutSocket.pm index d977570..c15aab6 100644 --- a/lib/Danga/TimeoutSocket.pm +++ b/lib/Danga/TimeoutSocket.pm @@ -25,6 +25,11 @@ sub new { sub max_idle_time { 0 } sub max_connect_time { 0 } +sub Reset { + Danga::Socket->Reset; + Danga::Socket->AddTimer(15, \&_do_cleanup); +} + sub _do_cleanup { my $now = time; diff --git a/qpsmtpd-async b/qpsmtpd-async index 392c9fe..457efb8 100755 --- a/qpsmtpd-async +++ b/qpsmtpd-async @@ -45,8 +45,8 @@ my $USER = (getpwuid $>)[0]; # user to suid to $USER = "smtpd" if $USER eq "root"; my $PAUSED = 0; my $NUMACCEPT = 20; -my $ACCEPT_RSET = Danga::Socket->AddTimer(30, \&reset_num_accept); -my $PID_FILE = ''; +my $PID_FILE = ''; +my $ACCEPT_RSET; my $DETACH; # daemonize on startup # make sure we don't spend forever doing accept() @@ -177,6 +177,8 @@ sub spawn_child { fileno($SERVER) => \&accept_handler, ); + $ACCEPT_RSET = Danga::Socket->AddTimer(30, \&reset_num_accept); + $plugin_loader->run_hooks('post-fork'); Qpsmtpd::PollServer->EventLoop(); @@ -380,7 +382,7 @@ sub accept_handler { # So double the number we accept next time. $NUMACCEPT *= 2; $NUMACCEPT = ACCEPT_MAX if $NUMACCEPT > ACCEPT_MAX; - $ACCEPT_RSET->cancel; + $ACCEPT_RSET->cancel if defined $ACCEPT_RSET; $ACCEPT_RSET = Danga::Socket->AddTimer(30, \&reset_num_accept); }