Skip to content

Commit

Permalink
Correct buffer size in the HTTP Emitter; remove artificial socket clo…
Browse files Browse the repository at this point in the history
…se timers
  • Loading branch information
roxblnfk committed Apr 14, 2024
1 parent 6bd6985 commit d927ec7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Handler/Http/Emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ final class Emitter
{
/**
* Preferred chunk size to be read from the stream before emitting. A value of 0 disables stream response.
* Value greater than 100 KB might not work with Linux Docker.
*/
public static int $bufferSize = 2_097_152; // 2MB
public static int $bufferSize = 1024 * 100;

/**
* Send {@see ResponseInterface} to the client.
Expand Down
5 changes: 3 additions & 2 deletions src/Socket/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ public function process(): void
}

if ($this->toDisconnect && $this->writeQueue === []) {
// Wait for the socket buffer to be flushed.
(new Timer(0.005))->wait();
# Wait for the socket buffer to be flushed.
// (new Timer(0.005))->wait();

throw new ClientDisconnected();
}
Fiber::suspend();
Expand Down
2 changes: 1 addition & 1 deletion src/Socket/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function __construct(
) {
$this->socket = @\socket_create_listen($port);
/** @link https://github.com/buggregator/trap/pull/14 */
\socket_set_option($this->socket, \SOL_SOCKET, \SO_LINGER, ['l_linger' => 0, 'l_onoff' => 1]);
// \socket_set_option($this->socket, \SOL_SOCKET, \SO_LINGER, ['l_linger' => 0, 'l_onoff' => 1]);

if ($this->socket === false) {
throw new \RuntimeException('Socket create failed.');
Expand Down

0 comments on commit d927ec7

Please sign in to comment.