Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7825efb

Browse files
Ensure we're talking to redis-server in our high ports test.
Instead of just checking whether or not something is listening on thehigh ports, send a quick PING to make sure.We're not just using another Redis instance because the point of thetest is to protect against a regression when connecting to high portnumbers.
1 parent5f6ce41 commit7825efb

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

‎tests/RedisTest.php‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7323,22 +7323,31 @@ public function testUnixSocket() {
73237323
}
73247324
}
73257325

7326+
protectedfunctiondetectRedis($host,$port) {
7327+
$sock = @fsockopen($host,$port,$errno,$errstr,.1);
7328+
if (!$sock)
7329+
returnfalse;
7330+
7331+
stream_set_timeout($sock,0,100000);
7332+
7333+
$ping_cmd ="*1\r\n$4\r\nPING\r\n";
7334+
if (fwrite($sock,$ping_cmd) !=strlen($ping_cmd))
7335+
returnfalse;
7336+
7337+
returnfread($sock,strlen("+PONG\r\n")) =="+PONG\r\n";
7338+
}
7339+
73267340
/* Test high ports if we detect Redis running there */
73277341
publicfunctiontestHighPorts() {
7328-
$arr_ports = [32767,32768,32769];
7329-
$arr_test_ports = [];
7330-
7331-
foreach ($arr_portsas$port) {
7332-
if (is_resource(@fsockopen('localhost',$port))) {
7333-
$arr_test_ports[] =$port;
7334-
}
7335-
}
7342+
$ports =array_filter(array_map(function ($port) {
7343+
return$this->detectRedis('localhost',$port) ?$port :0;
7344+
}, [32768,32769,32770]));
73367345

7337-
if ( !$arr_test_ports) {
7346+
if ( !$ports) {
73387347
return$this->markTestSkipped();
73397348
}
73407349

7341-
foreach ($arr_test_portsas$port) {
7350+
foreach ($portsas$port) {
73427351
$obj_r =newRedis();
73437352
try {
73447353
@$obj_r->connect('localhost',$port);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp