On 16-Nov-2002 wang bo wrote:
> pre-fork is easy in POE, i can create Component::Server::TCP
> and then create POE::Wheel::Run to run it. and the master
> server can use the wheels to send the instruction to child
> and get the child's output.
>
> but in the mode, the master server is accept the connection, too. i
> think
> it's better the master server don't accept
> the connection as same as apache. the simplest way is to post
> the event to make master server shutdown.
> i can use :
> $poe_kernel->post("server", "shutdown");
>
> but, if i do it, the master server can not create child process to
> accept
> and process the connection after component
> server shutdown, so it is impossible to implement the features
> like "MaxSpareServers" as same as apache.
>
>
> is there a way to remove a SocketFactory wheel (componet server tcp
> used)
> form kernel event loop and don't shutdown
> the wheel?
IKC does this by poking around behind the scenes. I've attached the code
below. Note that $heap is just a hashref that contains the wheel in
question at key 'wheel'.
Use this only if you want backwards compatibility or can't wait for
Rocco's {pause,resume}_accept().
-Philip
#----------------------------------------------------
# NOTE : THIS IS POORLY BEHAVED CODE
sub _select_define
{
my($heap, $on)=@_;
$on||=0;
DEBUG and
warn "_select_define (on=$on)";
my $state;
my $err="possible redefinition of POE internals";
$err="failure to bind to port" if $POE::VERSION <= 0.1005;
if($on) {
if(ref $heap->{wheel} eq 'HASH') {
$state=$heap->{wheel}->{'state_accept'};
} else {
$state=$heap->{wheel}->[5];
}
unless(defined $state) {
die "No 'state_accept' in $heap->{wheel}, $err.\n";
}
}
my $c=0;
if(ref $heap->{wheel} eq 'HASH') {
foreach my $hndl (qw(socket_handle)) {
next unless defined $heap->{wheel}->{$hndl};
$poe_kernel->select_read($heap->{wheel}->{$hndl}, $state);
$c++;
}
}
else {
$poe_kernel->select_read($heap->{wheel}->[0], $state);
$c++;
}
die "No socket_handle in $heap->{wheel}, $err.\n" unless $c;
return;
}