Skip to content

Commit e5e152a

Browse files
authored
Merge pull request #189 from clue-labs/memory
2 parents 3649a3f + 8efa0a5 commit e5e152a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Query/TcpTransportExecutor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class TcpTransportExecutor implements ExecutorInterface
127127
private $readBuffer = '';
128128
private $readPending = false;
129129

130+
/** @var string */
131+
private $readChunk = 0xffff;
132+
130133
/**
131134
* @param string $nameserver
132135
* @param ?LoopInterface $loop
@@ -181,7 +184,7 @@ public function query(Query $query)
181184
// set socket to non-blocking and wait for it to become writable (connection success/rejected)
182185
\stream_set_blocking($socket, false);
183186
if (\function_exists('stream_set_chunk_size')) {
184-
\stream_set_chunk_size($socket, (int) ((1 << 31) - 1)); // @codeCoverageIgnore
187+
\stream_set_chunk_size($socket, $this->readChunk); // @codeCoverageIgnore
185188
}
186189
$this->socket = $socket;
187190
}
@@ -270,7 +273,7 @@ public function handleRead()
270273
{
271274
// read one chunk of data from the DNS server
272275
// any error is fatal, this is a stream of TCP/IP data
273-
$chunk = @\fread($this->socket, 65536);
276+
$chunk = @\fread($this->socket, $this->readChunk);
274277
if ($chunk === false || $chunk === '') {
275278
$this->closeError('Connection to DNS server ' . $this->nameserver . ' lost');
276279
return;

0 commit comments

Comments
 (0)