Skip to content

Commit

Permalink
Workaround for HHVM.
Browse files Browse the repository at this point in the history
HHVM's implementation of socket_create returns a resource of type "stream"
instead of type "socket" causing \Net\Gearman\Connection::isConnected to
return false even when the connection is a valid resource.

See: facebook/hhvm#4036
  • Loading branch information
Daniel Bruce committed Oct 14, 2015
1 parent 29d21af commit 99754d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Net/Gearman/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,13 @@ static public function close($socket)
*/
static public function isConnected($conn)
{
$validResources = [
'socket' => true,
'stream' => true
];
return (is_null($conn) !== true &&
is_resource($conn) === true &&
strtolower(get_resource_type($conn)) == 'socket');
!empty($validResources[strtolower(get_resource_type($conn))]));
}

/**
Expand Down

0 comments on commit 99754d5

Please sign in to comment.