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