Subject: | POE::Component::Server::TCP - ClientConnected does not get a socket |
The documentation says ClientConnected should receive two arguments; the
newly connected socket, and the ClientArgs parameter. In fact,
ClientConnected only ever gets one argument, the ClientArgs parameter;
this is due to a fix some 4 years ago that splices ARG0 off of @_ to
pass to the POE::Wheel::ReadWrite constructor.
The simplest fix would be to just pass $_[ARG0], instead of splicing it
off of @_. However, any code that has dealt with not getting a socket
as ARG0 will break. Therefore, I've attached a patch that reorders the
arguments, passing the socket as ARG1.
Another alternative would be to not pass a socket at all; it remains
available via $_[HEAP]{'client'}->get_input_handle.
Subject: | reorder-args.patch |
--- TCP.pm-orig 2009-07-13 20:11:26.000000000 -0800
+++ TCP.pm-mod 2009-07-13 20:16:30.000000000 -0800
@@ -272,7 +272,7 @@
$heap->{remote_port} = $remote_port;
$heap->{client} = POE::Wheel::ReadWrite->new(
- Handle => splice(@_, ARG0, 1),
+ Handle => $_[ARG1],
Driver => POE::Driver::SysRW->new(),
_get_filters(
$client_filter,
@@ -373,7 +373,7 @@
package_states => $package_states,
object_states => $object_states,
- args => [ $socket, $args ],
+ args => [ $args, $socket ],
);
};
}
@@ -702,8 +702,8 @@
C<ClientConnected> is called at the end of the child session's
C<_start> routine. In addition to the usual C<_start> parameters, it
-includes the socket in $_[ARG0] and the contents of the component's
-C<Args> constructor parameter in $_[ARG1].
+includes the contents of the C<ClientArgs> constructor parameter in $_[ARG0],
+and the newly connected socket in $_[ARG1].
TODO - Should C<Args> be flattened into C<ARG1..$%_>?