--- deliantra/server/ext/dm-support.ext 2007/09/30 22:33:52 1.12 +++ deliantra/server/ext/dm-support.ext 2007/11/14 08:09:46 1.16 @@ -2,7 +2,6 @@ use Coro::Debug; use IO::Socket; -use Storable qw/nfreeze thaw/; my %global; # for use by eval'ed commands @@ -32,18 +31,20 @@ ext::books::reload & ext::map_tags::reload & ext::map_world::reload & +print JSON::XS->new->pretty->encode({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+$//; - select $fh; if ($cmd =~ /^\s*exit\b/i) { - print "will not exit() server.\n"; + print $fh "will not exit() server.\n"; } elsif ($cmd =~ s/^coro\s+// or $cmd =~ /^(?:ps|bt\s)/) { + select $fh; Coro::Debug::command $cmd; + select STDOUT; } else { my $sub = sub { package cf; @@ -77,18 +78,19 @@ } } - print "\n> "; - select STDOUT; + 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 }); + $LISTENER = EV::io $listen, EV::READ, sub { tcp_serve $listen->accept }; } }