Explorar o código

Check that socket is still alive before writing

Writing to a disconnected socket causes process to be terminated by SIGPIPE.
Here it also stop the routine "stop_server_without_decrypt" and causes to not stopping server.
NexusTiTi %!s(int64=5) %!d(string=hai) anos
pai
achega
44c127cb6d
Modificáronse 1 ficheiros con 8 adicións e 4 borrados
  1. 8 4
      KKrcon/HL2.pm

+ 8 - 4
KKrcon/HL2.pm

@@ -89,9 +89,13 @@ sub run {
 	}
 	}
 
 
 	my $socket = $self->socket();
 	my $socket = $self->socket();
-	print $socket $self->packet(CMD, $command);
-
-	return $self->response();
+	if($socket->connected)
+	{
+		print $socket $self->packet(CMD, $command);
+		return $self->response();
+	}
+	
+	return;
 }
 }
 
 
 # create tcp socket
 # create tcp socket
@@ -339,4 +343,4 @@ Chris Jones, E<lt>[email protected]<gt>
  it under the same terms as Perl itself, either Perl version 5.8.5 or,
  it under the same terms as Perl itself, either Perl version 5.8.5 or,
  at your option, any later version of Perl 5 you may have available.
  at your option, any later version of Perl 5 you may have available.
 
 
-=cut
+=cut