--- deliantra/server/ext/tcp.ext 2007/03/06 21:19:10 1.7 +++ deliantra/server/ext/tcp.ext 2008/05/05 09:03:46 1.11 @@ -10,7 +10,7 @@ our $LISTEN = new IO::Socket::INET LocalPort => cf::settings->csport, Listen => 1, - Blocking => 0, # bugfix workaround for Event calling handler twice :( + Blocking => 0, ReuseAddr => 1; if (!$LISTEN) { @@ -19,22 +19,22 @@ exit (2); } -Event->io ( - reentrant => 0, - fd => $LISTEN, - nice => 1, - poll => 'r', - data => cf::WF_AUTOCANCEL, - cb => sub { - my ($fh, $peername) = $LISTEN->accept - or return; - - my $fd = fileno $fh; - my $host = inet_ntoa +(sockaddr_in $peername)[1]; - - warn "new connection from $host\n"; - - cf::client::create $fd, $host; - }, -); +our $LISTENER = EV::io $LISTEN, EV::READ, sub { + my ($fh, $peername) = $LISTEN->accept + or return; + + my $fd = fileno $fh; + my $host = inet_ntoa +(sockaddr_in $peername)[1]; + + warn "new connection from $host\n"; + + # HACK to avoid blocking on common files on log-in. + # remove once async + cf::async {#d# + warn "HACK ext/tcp.ext: $cf::CONFDIR/$_\n" and Coro::AIO::aio_load "$cf::CONFDIR/$_", my $dummy for qw(rules news motd);#d# + warn "HACK ext/tcp.ext: $cf::LOCALDIR/crossfiremail\n" and Coro::AIO::aio_load "$cf::LOCALDIR/crossfiremail", my $dummy;#d# + cf::client::create $fd, $host; + undef $fh;#d# + };#d#d +};