mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-25 11:20:03 +00:00
Merge branch '3.0'
This commit is contained in:
commit
9983f00675
@ -2456,7 +2456,7 @@ class SSH2
|
||||
* Set Timeout
|
||||
*
|
||||
* $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout.
|
||||
* Setting $timeout to false or 0 will mean there is no timeout.
|
||||
* Setting $timeout to false or 0 will revert to the default socket timeout.
|
||||
*/
|
||||
public function setTimeout(int $timeout): void
|
||||
{
|
||||
@ -3130,11 +3130,11 @@ class SSH2
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[] second and microsecond stream timeout options based on user-requested timeout and keep-alive, 0 by default
|
||||
* @return int[] second and microsecond stream timeout options based on user-requested timeout and keep-alive, or the default socket timeout by default, which mirrors PHP socket streams.
|
||||
*/
|
||||
private function get_stream_timeout()
|
||||
{
|
||||
$sec = 0;
|
||||
$sec = ini_get('default_socket_timeout');
|
||||
$usec = 0;
|
||||
if ($this->curTimeout > 0) {
|
||||
$sec = (int) floor($this->curTimeout);
|
||||
|
@ -225,9 +225,10 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
*/
|
||||
public function testGetStreamTimeout(): void
|
||||
{
|
||||
$default = ini_get('default_socket_timeout');
|
||||
// no curTimeout, no keepAlive
|
||||
$ssh = $this->createSSHMock();
|
||||
$this->assertEquals([0, 0], self::callFunc($ssh, 'get_stream_timeout'));
|
||||
$this->assertEquals([$default, 0], self::callFunc($ssh, 'get_stream_timeout'));
|
||||
|
||||
// curTimeout, no keepAlive
|
||||
$ssh = $this->createSSHMock();
|
||||
|
Loading…
Reference in New Issue
Block a user