diff --git a/composer.json b/composer.json index 3f1c7db5..580373e9 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require": { "php": ">=8.2", "freedsx/asn1": "dev-main#bb89093", - "freedsx/socket": "dev-main#756a6e6", + "freedsx/socket": "dev-main#45fe6ca", "freedsx/sasl": "dev-main#525d0e9", "psr/log": "^3" }, diff --git a/src/FreeDSx/Ldap/Server/SocketServerFactory.php b/src/FreeDSx/Ldap/Server/SocketServerFactory.php index 720a0a04..b553d083 100644 --- a/src/FreeDSx/Ldap/Server/SocketServerFactory.php +++ b/src/FreeDSx/Ldap/Server/SocketServerFactory.php @@ -75,7 +75,8 @@ public function makeAndBind(): SocketServer ->setSslAllowSelfSigned($this->network->getSslAllowSelfSigned()) ->setSslCaCert($this->network->getSslCaCert()) ->setTimeoutHandshake($this->network->getSslHandshakeTimeout()) - ->setReusePort($this->reusePort); + ->setReusePort($this->reusePort) + ->setTcpNoDelay(!$isUnixSocket); return SocketServer::bind( $resource, diff --git a/tests/unit/Server/SocketServerFactoryTest.php b/tests/unit/Server/SocketServerFactoryTest.php index 35f40892..18dfc3b1 100644 --- a/tests/unit/Server/SocketServerFactoryTest.php +++ b/tests/unit/Server/SocketServerFactoryTest.php @@ -185,6 +185,25 @@ public function test_it_should_make_a_unix_based_socket_server(): void $this->subject->makeAndBind(); } + public function test_it_disables_nagle_on_tcp_connections(): void + { + self::assertTrue($this->subject->makeAndBind()->getOptions()->isTcpNoDelay()); + } + + public function test_it_leaves_nagle_alone_on_a_unix_socket(): void + { + $this->requireUnix('Cannot construct unix based socket on Windows.'); + + $subject = new SocketServerFactory( + (new NetworkConfig()) + ->setUnixSocket($this->tmpUnixSocketFilePath) + ->setTransport('unix'), + RunnerMode::Pcntl, + ); + + self::assertFalse($subject->makeAndBind()->getOptions()->isTcpNoDelay()); + } + public function test_an_existing_socket_that_is_not_writeable_is_recorded_and_refused(): void { $this->requireUnix('Cannot construct unix based socket on Windows.');