1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 06:06:40 +02:00

Avoid infinite loops when no data is written on a socket for a time greater than writingTimeout settings

This commit is contained in:
Danilo Silva
2015-10-19 12:02:32 +02:00
parent fa74e171dc
commit 5c129a7f7f
2 changed files with 71 additions and 0 deletions

View File

@@ -235,6 +235,26 @@ class SocketHandlerTest extends TestCase
$this->assertTrue(is_resource($this->res));
}
/**
* @expectedException \RuntimeException
*/
public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
{
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
$this->handler->expects($this->any())
->method('fwrite')
->will($this->returnValue(0));
$this->handler->expects($this->any())
->method('streamGetMetadata')
->will($this->returnValue(array('timed_out' => false)));
$this->handler->setWritingTimeout(1);
$this->writeRecord('Hello world');
}
private function createHandler($connectionString)
{
$this->handler = new SocketHandler($connectionString);