THRIFT-3643 Perl SSL server crushes if a client disconnect without handshake
Client: Perl
Patch: Nobuaki Sukegawa
This closes #874
diff --git a/lib/perl/lib/Thrift/SSLSocket.pm b/lib/perl/lib/Thrift/SSLSocket.pm
index b70d46f..0d2edf8 100644
--- a/lib/perl/lib/Thrift/SSLSocket.pm
+++ b/lib/perl/lib/Thrift/SSLSocket.pm
@@ -54,7 +54,9 @@
{
my $self = shift;
my $sock = ($self->{handle}->handles())[0];
- $sock->close(SSL_no_shutdown => 1);
+ if ($sock) {
+ $sock->close(SSL_no_shutdown => 1);
+ }
}
sub __recv
@@ -63,8 +65,10 @@
my $sock = shift;
my $len = shift;
my $buf = undef;
+ if ($sock) {
sysread($sock, $buf, $len);
- return $buf;
+ }
+ return $buf;
}
sub __send
@@ -79,7 +83,7 @@
{
my $self = shift;
my $sock = ($self->{handle}->handles())[0];
- if ($sock->pending() eq 0) {
+ if ($sock and $sock->pending() eq 0) {
return $self->SUPER::__wait();
}
return $sock;