Skip to content

Commit cc365ab

Browse files
author
Andrew Carter
committed
Added error checking into DaemonFactory
1 parent 1ba8caa commit cc365ab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/DaemonFactory.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public function createDaemon($kernel)
1919
{
2020
$socket = fopen('php://fd/'.DaemonInterface::FCGI_LISTENSOCK_FILENO, 'r');
2121

22+
if (false === $socket) {
23+
throw new \RuntimeException('Could not open FCGI_LISTENSOCK_FILENO');
24+
}
25+
2226
return $this->createDaemonFromStreamSocket($kernel, $socket);
2327
}
2428

@@ -29,7 +33,12 @@ public function createDaemon($kernel)
2933
*/
3034
public function createTcpDaemon($kernel, $port, $host = 'localhost')
3135
{
32-
$socket = stream_socket_server('tcp://'.$host.':'.$port);
36+
$address = 'tcp://'.$host.':'.$port;
37+
$socket = stream_socket_server($address);
38+
39+
if (false === $socket) {
40+
throw new \RuntimeException('Could not create stream socket server on: '.$address);
41+
}
3342

3443
return $this->createDaemonFromStreamSocket($kernel, $socket);
3544
}

0 commit comments

Comments
 (0)