cvs commit: qpsmtpd/lib/Qpsmtpd SelectServer.pm

[email protected] (Matt Sergeant)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     03/11/02 09:36:36

  Modified:    lib/Qpsmtpd SelectServer.pm
  Log:
  Support SIGTERM
  
  Revision  Changes    Path
  1.3       +7 -1      qpsmtpd/lib/Qpsmtpd/SelectServer.pm
  
  Index: SelectServer.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/SelectServer.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- SelectServer.pm	2 Nov 2003 17:34:33 -0000	1.2
  +++ SelectServer.pm	2 Nov 2003 17:36:36 -0000	1.3
  @@ -23,6 +23,10 @@
   my $server;
   my $select;
   
  +our $QUIT = 0;
  +
  +$SIG{INT} = $SIG{TERM} = sub { $QUIT++ };
  +
   sub main {
       my $class = shift;
       my %opts = (LocalPort => 25, Reuse => 1, Listen => SOMAXCONN, @_);
  @@ -34,7 +38,9 @@
       $select = IO::Select->new($server);
       my $res = Net::DNS::Resolver->new;
       
  -    while (1) {
  +    # TODO - make this more graceful - let all current SMTP sessions finish
  +    # before quitting!
  +    while (!$QUIT) {
           foreach my $client ($select->can_read(1)) {
               if ($client == $server) {
                   my $client_addr;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.