1
0
mirror of https://github.com/danog/ipc.git synced 2024-11-26 20:15:05 +01:00

Fix long URIs

This commit is contained in:
Daniil Gentili 2021-05-03 15:34:15 +02:00
parent be76cf8125
commit faa13a43aa
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 11 additions and 6 deletions

View File

@ -49,12 +49,16 @@ class IpcServer
} else {
throw new \RuntimeException("Cannot use FIFOs and UNIX sockets on windows");
}
$listenUri = "tcp://127.0.0.1:0";
} elseif ($type === self::TYPE_AUTO) {
$types = [self::TYPE_UNIX, self::TYPE_TCP, self::TYPE_FIFO];
$types = [];
if (strlen($uri) <= 104) {
$types []= self::TYPE_UNIX;
}
$types []= self::TYPE_FIFO;
$types []= self::TYPE_TCP;
} else {
$types = [];
if ($type & self::TYPE_UNIX) {
if ($type & self::TYPE_UNIX && strlen($uri) <= 104) {
$types []= self::TYPE_UNIX;
}
if ($type & self::TYPE_TCP) {
@ -63,7 +67,6 @@ class IpcServer
if ($type & self::TYPE_FIFO) {
$types []= self::TYPE_FIFO;
}
$listenUri = "unix://".$uri;
}
$errors = [];

View File

@ -60,14 +60,16 @@ class IpcTest extends AsyncTestCase
public function provideUriType(): \Generator
{
foreach (['', \sys_get_temp_dir().'/pony'] as $uri) {
foreach (['', \sys_get_temp_dir().'/pony', \sys_get_temp_dir().'/'.str_repeat('a', 200)] as $uri) {
if (\strncasecmp(\PHP_OS, "WIN", 3) === 0) {
yield [$uri, IpcServer::TYPE_AUTO];
yield [$uri, IpcServer::TYPE_TCP];
} else {
yield [$uri, IpcServer::TYPE_AUTO];
yield [$uri, IpcServer::TYPE_TCP];
yield [$uri, IpcServer::TYPE_UNIX];
if (\strlen($uri) < 200) {
yield [$uri, IpcServer::TYPE_UNIX];
}
yield [$uri, IpcServer::TYPE_FIFO];
}
}