mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 03:27:31 +00:00
Merge pull request #2023 from rposky/ssh-default-socket-timeout
SSH2: Defer to default socket timeout in absence of more specific value
This commit is contained in:
commit
47895e2851
@ -2747,7 +2747,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.
|
||||
*
|
||||
* @param mixed $timeout
|
||||
*/
|
||||
@ -3462,11 +3462,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);
|
||||
|
@ -228,9 +228,10 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
*/
|
||||
public function testGetStreamTimeout()
|
||||
{
|
||||
$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