Skip to content

Commit 54d252a

Browse files
committed
close tcp socket after check service
1 parent 02ea578 commit 54d252a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

functions.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,23 @@ function run(){
5151
function checkService($service, $try = 1){
5252
list($ip, $port) = explode(':', $service);
5353
$this->config['results'][$service] = array();
54-
$this->config['results'][$service]['result'] = @fsockopen(
54+
$fp = @fsockopen(
5555
$ip,
5656
$port,
5757
$this->config['results'][$service]['errno'],
5858
$this->config['results'][$service]['errstr'],
5959
$this->config['timeout']
6060
);
61-
if (!$this->config['results'][$service]['result']){
61+
if ($fp){
62+
@fclose($fp);
63+
}else{
6264
$this->error("$service is down ($try/{$this->config['try']})");
6365
if ($try < $this->config['try']){
6466
sleep($this->config['timeout']);
6567
return $this->checkService($service, $try + 1);
6668
}
6769
}
68-
return $this->config['results'][$service]['result'];
70+
return $this->config['results'][$service]['result'] = $fp;
6971
}
7072

7173
/**

0 commit comments

Comments
 (0)