Skip to content

Commit ef7bc23

Browse files
Throw an exception whenever a socket drops connection unexpectedly
1 parent a7d15d5 commit ef7bc23

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/Crusse/JobServer/EventLoop.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,10 @@ private function getMessagesFromSocket( $socket ) {
285285
throw new \Exception( socket_strerror( socket_last_error() ) );
286286
}
287287

288-
// Connection was dropped by peer
289-
if ( $dataLen === 0 ) {
290-
// Don't read/write from/to this socket in the future
291-
$this->disconnect( $this->sockets[ $socketIndex ] );
292-
unset( $this->sockets[ $socketIndex ] );
293-
return array();
294-
}
288+
// Connection was dropped by peer. We expects peers to be dropped only after
289+
// $this->stop() has been called, so this is unexpected.
290+
if ( $dataLen === 0 )
291+
throw new \Exception( 'Socket disconnected unexpectedly' );
295292

296293
$this->log( 'Recvd '. $dataLen .' b from '. $socketIndex );
297294
$this->populateMessageBuffer( $data, $buffer );

0 commit comments

Comments
 (0)