--- deliantra/server/ext/tcp.ext 2006/12/15 19:29:18 1.1 +++ deliantra/server/ext/tcp.ext 2007/03/06 21:19:10 1.7 @@ -10,22 +10,31 @@ our $LISTEN = new IO::Socket::INET LocalPort => cf::settings->csport, Listen => 1, + Blocking => 0, # bugfix workaround for Event calling handler twice :( ReuseAddr => 1; if (!$LISTEN) { # extension yes, completely stupid, not yet - warn "unable to establish listen sockect, exiting.\n"; + warn "unable to establish listen socket, exiting.\n"; exit (2); } -Event->io (fd => $LISTEN, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub { - my ($fh, $peername) = $LISTEN->accept - or return; +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]; + my $fd = fileno $fh; + my $host = inet_ntoa +(sockaddr_in $peername)[1]; - warn "new connection from $host\n"; + warn "new connection from $host\n"; + + cf::client::create $fd, $host; + }, +); - cf::add_client_socket $fd, $host; -});