Skip to content

Commit 12820c7

Browse files
committed
Fix BSDSocket::setTimeout()
1 parent 14b5829 commit 12820c7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/php/peer/BSDSocket.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ public function setTimeout($timeout) {
245245
$this->_timeout= $timeout;
246246

247247
// Apply changes to already opened connection
248-
$s= (int)$this->_timeout;
249-
$usec= (int)(1000 * ($this->_timeout - $s);
250-
$this->setOption(SOL_SOCKET, SO_RCVTIMEO, ['sec' => $s, 'usec' => $usec]);
251-
$this->setOption(SOL_SOCKET, SO_SNDTIMEO, ['sec' => $s, 'usec' => $usec]);
248+
$sec= (int)$this->_timeout;
249+
$usec= (int)(1000 * ($this->_timeout - $sec));
250+
$this->setOption(SOL_SOCKET, SO_RCVTIMEO, ['sec' => $sec, 'usec' => $usec]);
251+
$this->setOption(SOL_SOCKET, SO_SNDTIMEO, ['sec' => $sec, 'usec' => $usec]);
252252
}
253253

254254
/**

src/test/php/peer/unittest/sockets/AbstractSocketTest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function setUp() {
6262

6363
/** @return void */
6464
public function tearDown() {
65-
$this->fixture->isConnected() && $this->fixture->close();
65+
$this->fixture && $this->fixture->isConnected() && $this->fixture->close();
6666
}
6767

6868
#[Test]

0 commit comments

Comments
 (0)