Skip Menu |

This queue is for tickets about the Net-Server CPAN distribution.

Report information
The Basics
Id: 31437
Status: resolved
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: cpan [...] chmrr.net
Cc:
AdminCc:

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



Subject: ->accept returns two values in wantarray context; skip SSL undefs
Heya, The attached patch fixes two bugs in Net::Server. Firstly, the accept method of Net::Server::Proto::* should return two values in array context, to maintain compatibility with IO::Socket, which they inherit from. Secondly, IO::Socket::SSL's default values for certificate location and the like are overriden by the 'undef' defaults that Net::Server::Proto::SSL passes in. The attached patch skips undef values when calling ->configure, which allows IO::Socket::SSL's default values to kick in. - Alex
Subject: server-socket.diff
diff -ruN Net-Server-0.97/lib/Net/Server/Proto/SSL.pm Net-Server-0.97-modified/lib/Net/Server/Proto/SSL.pm --- Net-Server-0.97/lib/Net/Server/Proto/SSL.pm 2007-02-03 00:56:34.000000000 -0500 +++ Net-Server-0.97-modified/lib/Net/Server/Proto/SSL.pm 2007-12-12 17:43:47.000000000 -0500 @@ -104,7 +104,7 @@ ### add in any ssl specific properties foreach ( keys %$prop ){ next unless /^SSL_/; - $args{$_} = $prop->{$_}; + $args{$_} = $prop->{$_} if defined $prop->{$_}; } ### connect to the sock @@ -130,15 +130,15 @@ ### allow for endowing the child sub accept { my $sock = shift; - my $client = $sock->SUPER::accept(); + my($client, $peername) = $sock->SUPER::accept(); ### pass items on - if( defined($client) ){ + if( $peername ){ bless $client, ref($sock); $client->NS_proto( $sock->NS_proto ); } - return $client; + return wantarray ? ($client, $peername) : $client; } ### a string containing any information necessary for restarting the server diff -ruN Net-Server-0.97/lib/Net/Server/Proto/TCP.pm Net-Server-0.97-modified/lib/Net/Server/Proto/TCP.pm --- Net-Server-0.97/lib/Net/Server/Proto/TCP.pm 2007-02-03 00:55:56.000000000 -0500 +++ Net-Server-0.97-modified/lib/Net/Server/Proto/TCP.pm 2007-12-12 17:43:47.000000000 -0500 @@ -107,14 +107,14 @@ ### allow for endowing the child sub accept { my $sock = shift; - my $client = $sock->SUPER::accept(); + my($client, $peername) = $sock->SUPER::accept(); ### pass items on - if( defined($client) ){ + if( $peername ){ $client->NS_proto( $sock->NS_proto ); } - return $client; + return wantarray ? ($client, $peername) : $client; } ### a string containing any information necessary for restarting the server
Thank you for the report. I updated all of the accept code to return properly in wantarray - and additionally to take a classname as an argument. I've also fixed the ssl undefs. Thank you for the report.
Subject: Re: [rt.cpan.org #31437] ->accept returns two values in wantarray context; skip SSL undefs
Date: Mon, 12 Nov 2012 03:52:56 -0500
To: bug-Net-Server [...] rt.cpan.org
From: Alex Vandiver <alex [...] chmrr.net>
On Wed, 2012-05-30 at 15:31 -0400, Paul Seamons via RT wrote: Show quoted text
> Thank you for the report. I updated all of the accept code to return > properly in wantarray - and additionally to take a classname as an argument.
Unfortunately, the code to Net::Server::Proto::TCP is currently (as of version 2.06): sub accept { my ($sock, $class) = (@_); my ($client, $peername); if (wantarray) { ($client, $peername) = $sock->SUPER::accept($class); } else { $client = $sock->SUPER::accept($class); } if (defined $client) { $client->NS_port($sock->NS_port); } return $client; } While this checks wantarray, it always returns a single value, regardless of how it is called. The last line should read: return wantarray ? ($client, $peername) : $client; Net::Server::Proto::SSL and Net::Server::Proto::SSLEAY get this correct. - Alex
Subject: Re: [rt.cpan.org #31437] ->accept returns two values in wantarray context; skip SSL undefs
Date: Mon, 12 Nov 2012 05:30:14 -0700
To: bug-Net-Server [...] rt.cpan.org
From: Rob Brown <bbb [...] cpan.org>
Yes, good catch Alex. Your solution seems appropriate. On Mon, Nov 12, 2012 at 1:53 AM, Alex Vandiver via RT < bug-Net-Server@rt.cpan.org> wrote: Show quoted text
> > Unfortunately, the code to Net::Server::Proto::TCP is currently (as of > version 2.06): > > sub accept { > my ($sock, $class) = (@_); > my ($client, $peername); > if (wantarray) { > ($client, $peername) = $sock->SUPER::accept($class); > } else { > $client = $sock->SUPER::accept($class); > } > if (defined $client) { > $client->NS_port($sock->NS_port); > } > return $client; > } > > While this checks wantarray, it always returns a single value, > regardless of how it is called. The last line should read: > > return wantarray ? ($client, $peername) : $client; > > Net::Server::Proto::SSL and Net::Server::Proto::SSLEAY get this correct. > - Alex > > >
Fixed in the just uploaded 2.007