respect timeout in native backend

This commit is contained in:
Robin Appelman 2018-08-24 15:20:33 +02:00
commit 24e0162914
3 changed files with 6 additions and 3 deletions

View file

@ -25,7 +25,7 @@ class NativeServer extends AbstractServer {
} }
protected function connect() { protected function connect() {
$this->state->init($this->getAuth()); $this->state->init($this->getAuth(), $this->getOptions());
} }
/** /**

View file

@ -53,7 +53,7 @@ class NativeShare extends AbstractShare {
} }
$this->state = new NativeState(); $this->state = new NativeState();
$this->state->init($this->server->getAuth()); $this->state->init($this->server->getAuth(), $this->server->getOptions());
return $this->state; return $this->state;
} }

View file

@ -21,6 +21,7 @@ use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\OutOfSpaceException; use Icewind\SMB\Exception\OutOfSpaceException;
use Icewind\SMB\Exception\TimedOutException; use Icewind\SMB\Exception\TimedOutException;
use Icewind\SMB\IAuth; use Icewind\SMB\IAuth;
use Icewind\SMB\IOptions;
/** /**
* Low level wrapper for libsmbclient-php with error handling * Low level wrapper for libsmbclient-php with error handling
@ -76,14 +77,16 @@ class NativeState {
/** /**
* @param IAuth $auth * @param IAuth $auth
* @param IOptions $options
* @return bool * @return bool
*/ */
public function init(IAuth $auth) { public function init(IAuth $auth, IOptions $options) {
if ($this->connected) { if ($this->connected) {
return true; return true;
} }
$this->state = smbclient_state_new(); $this->state = smbclient_state_new();
smbclient_option_set($this->state, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, false); smbclient_option_set($this->state, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, false);
smbclient_option_set($this->state, SMBCLIENT_OPT_TIMEOUT, $options->getTimeout() * 1000);
$auth->setExtraSmbClientOptions($this->state); $auth->setExtraSmbClientOptions($this->state);
$result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword()); $result = @smbclient_state_init($this->state, $auth->getWorkgroup(), $auth->getUsername(), $auth->getPassword());