Skip to content

Commit 0481fcd

Browse files
balpingJens-G
authored andcommitted
THRIFT-1482 Allow unix domain sockets in TSocket
Client: php Patch: Balázs Dura-Kovács This closes #3109
1 parent 4bacc1a commit 0481fcd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/php/lib/Transport/TSocket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function open()
218218
throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
219219
}
220220

221-
if ($this->port_ <= 0) {
221+
if ($this->port_ <= 0 && strpos($this->host_, 'unix://') !== 0) {
222222
throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
223223
}
224224

lib/php/test/Unit/Lib/Transport/TSocketTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,33 @@ public function testOpenPersist()
246246
$this->assertTrue($transport->isOpen());
247247
}
248248

249+
public function testOpenUnixSocket()
250+
{
251+
$host = 'unix:///tmp/ipc.sock';
252+
$port = -1;
253+
$persist = false;
254+
$debugHandler = null;
255+
256+
$this->getFunctionMock('Thrift\Transport', 'fsockopen')
257+
->expects($this->once())
258+
->with(
259+
$host,
260+
$port,
261+
$this->anything(), #$errno,
262+
$this->anything(), #$errstr,
263+
$this->anything() #$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000),
264+
);
265+
266+
$transport = new TSocket(
267+
$host,
268+
$port,
269+
$persist,
270+
$debugHandler
271+
);
272+
273+
$transport->open();
274+
}
275+
249276
/**
250277
* @dataProvider open_THRIFT_5132_DataProvider
251278
*/

0 commit comments

Comments
 (0)