--- deliantra/server/ext/dm-support.ext 2007/10/12 19:13:26 1.14 +++ deliantra/server/ext/dm-support.ext 2009/06/28 16:46:50 1.23 @@ -31,10 +31,12 @@ ext::books::reload & ext::map_tags::reload & ext::map_world::reload & +while (EV::TIMEOUT & Coro::EV::timed_io_once \$fh, EV::READ, 1) { Coro::Debug::command "ps" } & +({cf::mallinfo}) EOF print $fh "\n> "; - Event->io (fd => $fh, poll => 'r', data => 0, cb => sub { + my $iow; $iow = EV::io $fh, EV::READ, sub { if (defined (my $cmd = <$fh>)) { $cmd =~ s/\s+$//; @@ -49,8 +51,8 @@ package cf; select $fh; - # compile first, the execute, as Coro does not support switching in eval string - my $cb = eval "sub { $cmd }"; + # compile first, then execute, as Coro does not support switching in eval string + my $cb = eval "sub { $cmd \n}"; my $t1 = Time::HiRes::time; my @res = $@ ? () : eval { $cb->() }; @@ -79,15 +81,17 @@ print $fh "\n> "; } else { - $_[0]->w->cancel; + undef $iow; } - }); + }; } +our $LISTENER; + # now a shell listening on a tcp-port - let the firewall decide access rights if ($cf::CFG{perl_shell}) { - if (my $listen = new IO::Socket::INET LocalAddr => $cf::CFG{perl_shell}, Listen => 1, ReuseAddr => 1) { - Event->io (fd => $listen, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub { tcp_serve $listen->accept }); + if (my $listen = new IO::Socket::INET LocalAddr => $cf::CFG{perl_shell}, Listen => 1, ReuseAddr => 1, Blocking => 0) { + $LISTENER = EV::io $listen, EV::READ, sub { tcp_serve $listen->accept }; } }