correct way for a prefork server
Aleksandar Lazic
al-anyevent at none.at
Thu Dec 2 11:13:55 CET 2010
Dear list member,
I want to 'AnyEvent'ify the qpsmtpd-prefork
http://svn.perl.org/qpsmtpd/trunk/qpsmtpd-prefork
About qpsmtpd (http://wiki.qpsmtpd.org/)
###
The qpsmtpd daemon started as a replacement daemon for the qmail-smtpd
SMTP receiver from the qmail mail transport agent (MTA).
....
The qpsmtpd daemon, on the other hand, is Perl and can be customized
easily.
It consists of a core that implements a complete SMTP server, and a
number of plug-ins that enhance the operations of the server.
These plug-ins allow for the checking of recipients and senders, as well
as virus scanning, spam checking, blocking lists (DNS and RHS), SMTP
AUTH and TLS. The qpsmtpd daemon, on the other hand, is Perl and can be
customized easily. It consists of a core that implements a complete SMTP
server, and a number of plug-ins that enhance the operations of the
server. These plug-ins allow for the checking of recipients and senders,
as well as virus scanning, spam checking, blocking lists (DNS and RHS),
SMTP AUTH and TLS.
###
Now I try to collect the 'right' way.
Questions:
The module use IO::Select & IO::Socket::INET can I completley substitute
the listen part with 'tcp_server ... accept_callback'?
###qpsmtpd-prefork
for my $addr (@d_addr) {
my @Socket_opts = (
LocalPort => $addr->{port},
LocalAddr => $addr->{addr},
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1,
);
# create new socket (used by clients to communicate with daemon)
my $s;
if ($has_ipv6) {
$s = IO::Socket::INET6->new(@Socket_opts);
}
else {
$s = IO::Socket::INET->new(@Socket_opts);
}
die "FATAL: Failed to open socket on $addr->{addr}:$addr->{port} ($@)"
. "\nIt may be necessary to wait 20 secs before starting daemon"
. " again."
unless $s;
$select->add($s);
}
###
### idea
for my $addr (@d_addr) {
tcp_server $addr->{addr}, $addr->{port}, accept_callback;
}
###
Is it worth to use AnyEvent::Worker::Pool to avoid forks on every
request
BR
Aleks
More information about the anyevent
mailing list