| 149 | } |
| 150 | |
| 151 | void ThriftServer::ThriftServerEventProcessor::Supervise() { |
| 152 | DCHECK(thrift_server_->server_.get() != NULL); |
| 153 | try { |
| 154 | thrift_server_->server_->serve(); |
| 155 | } catch (TException& e) { |
| 156 | LOG(ERROR) << "ThriftServer '" << thrift_server_->name_ << "' (on port: " |
| 157 | << thrift_server_->port_ << ") exited due to TException: " << e.what(); |
| 158 | } |
| 159 | { |
| 160 | // signal_lock_ ensures mutual exclusion of access to thrift_server_ |
| 161 | lock_guard<mutex> lock(signal_lock_); |
| 162 | thrift_server_->started_ = false; |
| 163 | |
| 164 | // There may not be anyone waiting on this signal (if the |
| 165 | // exception occurs after startup). That's not a problem, this is |
| 166 | // just to avoid waiting for the timeout in case of a bind |
| 167 | // failure, for example. |
| 168 | signal_fired_ = true; |
| 169 | } |
| 170 | signal_cond_.NotifyAll(); |
| 171 | } |
| 172 | |
| 173 | void ThriftServer::ThriftServerEventProcessor::preServe() { |
| 174 | // Acquire the signal lock to ensure that StartAndWaitForServer is |