diff options
author | 2015-08-13 11:12:54 -0700 | |
---|---|---|
committer | 2015-08-13 11:12:54 -0700 | |
commit | 1567c0c9a624ffab4ab786979573c41a5bce2c2c (patch) | |
tree | 3f766ea92604f1f21fbed2193912365b4ff3e135 /src/php/lib/Grpc | |
parent | 04b7a41d18744d2e882a486862ec2afb7433655f (diff) |
php: connectivity state review feedback
Diffstat (limited to 'src/php/lib/Grpc')
-rwxr-xr-x | src/php/lib/Grpc/BaseStub.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index dc507df92c..9d6a77b855 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -85,8 +85,9 @@ class BaseStub { /** * @param $timeout in microseconds * @return bool true if channel is ready + * @throw Exception if channel is in FATAL_ERROR state */ - public function watchForReady($timeout) { + public function waitForReady($timeout) { $new_state = $this->getConnectivityState(true); if ($this->_checkConnectivityState($new_state)) { return true; @@ -96,14 +97,16 @@ class BaseStub { $delta = new Timeval($timeout); $deadline = $now->add($delta); - if (!$this->channel->watchConnectivityState($new_state, $deadline)) { - return false; + while ($this->channel->watchConnectivityState($new_state, $deadline)) { + // state has changed before deadline + $new_state = $this->getConnectivityState(); + if ($this->_checkConnectivityState($new_state)) { + return true; + } } + // deadline has passed $new_state = $this->getConnectivityState(); - if ($this->_checkConnectivityState($new_state)) { - return true; - } - return false; + return $this->_checkConnectivityState($new_state); } private function _checkConnectivityState($new_state) { |