Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 47852
Status: resolved
Worked: 15 min
Priority: 0/
Queue: POE

People
Owner: BINGOS [...] cpan.org
Requestors: mlf-bitcard [...] shoebox.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: POE::Component::Server::TCP - ClientArgs is passed to the listener, too
The ClientArgs parameter to new() is being passed to the listener session, as well as to each client session. The documentation doesn't mention this, and the name of the parameter itself implies it's client-only. The simple fix is to just not pass it as args to the listener session. The more useful fix (potentially) is to provide a ListenerArgs parameter that is passed directly to the listener session. I have provided a patch for this case. Probably the most conservative fix would be to document that ClientArgs is passed to both listener and clients. The name becomes a bit confusing in that case.
Subject: ListenerArgs.patch
--- TCP.pm-orig 2009-07-13 19:16:20.000000000 -0800 +++ TCP.pm-mod 2009-07-13 19:33:38.000000000 -0800 @@ -100,6 +100,11 @@ my $session_type = delete $param{SessionType}; my $session_params = delete $param{SessionParams}; my $server_started = delete $param{Started}; + my $listener_args = delete $param{ListenerArgs}; + + $listener_args = [] unless defined $listener_args; + croak "ListenerArgs must be an array reference" + unless ref($listener_args) eq 'ARRAY'; if (exists $param{Args}) { if (exists $param{ClientArgs}) { @@ -111,7 +116,7 @@ } } - my $args = delete($param{ClientArgs}) || delete($param{Args}); + my $client_args = delete($param{ClientArgs}) || delete($param{Args}); # Defaults. @@ -140,7 +145,7 @@ $client_connected = sub {} unless defined $client_connected; $client_disconnected = sub {} unless defined $client_disconnected; $client_flushed = sub {} unless defined $client_flushed; - $args = [] unless defined $args; + $client_args = [] unless defined $client_args; # Extra states. @@ -168,7 +173,7 @@ unless ref($object_states) eq 'ARRAY'; croak "ClientArgs must be an array reference" - unless ref($args) eq 'ARRAY'; + unless ref($client_args) eq 'ARRAY'; # Sanity check, thanks to crab@irc for making this mistake, ha! # TODO we could move this to POE::Session and make it a @@ -373,7 +378,7 @@ package_states => $package_states, object_states => $object_states, - args => [ $socket, $args ], + args => [ $socket, $client_args ], ); }; } @@ -504,7 +509,7 @@ _child => sub { }, }, - args => $args, + args => $listener_args, )->ID; # Return the session ID. @@ -964,6 +969,12 @@ fully started. The callback's parameters are the usual for a session's _start handler. +=head4 ListenerArgs + +C<ListenerArgs> is passed to the listener session as the C<args> parameter. In +other words, it must be an arrayref, and the values are are passed into the +C<Started> handler as ARG0, ARG1, etc. + =head3 Connection Session Configuration These constructor parameters affect the individual sessions that
Subject: Re: [rt.cpan.org #47852] POE::Component::Server::TCP - ClientArgs is passed to the listener, too
Date: Fri, 17 Jul 2009 08:50:39 +0100
To: Michael Fowler via RT <bug-POE [...] rt.cpan.org>
From: "Chris 'BinGOs' Williams" <chris [...] bingosnet.co.uk>
On Mon, Jul 13, 2009 at 11:36:39PM -0400, Michael Fowler via RT wrote: Show quoted text
> Mon Jul 13 23:36:37 2009: Request 47852 was acted upon. > Transaction: Ticket created by mlfowler > Queue: POE > Subject: POE::Component::Server::TCP - ClientArgs is passed to the > listener, too > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: mlf-bitcard@shoebox.net > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=47852 > > > > The ClientArgs parameter to new() is being passed to the listener > session, as well as to each client session. The documentation doesn't > mention this, and the name of the parameter itself implies it's client-only. > > The simple fix is to just not pass it as args to the listener session. > > The more useful fix (potentially) is to provide a ListenerArgs parameter > that is passed directly to the listener session. I have provided a > patch for this case. > > Probably the most conservative fix would be to document that ClientArgs > is passed to both listener and clients. The name becomes a bit > confusing in that case. >
Thanks applied to repo as at r2567 http://github.com/bingos/poe/commit/6f51ad1f4729689fe69b488d0608ddaa09fd87ae -- Chris Williams aka BinGOs PGP ID 0x4658671F http://www.gumbynet.org.uk ==========================
Download (untitled)
application/pgp-signature 189b

Message body not shown because it is not plain text.

Closing ticket.