NOTE: Join() can happen before StopAccept()
| 174 | |
| 175 | // NOTE: Join() can happen before StopAccept() |
| 176 | void Acceptor::Join() { |
| 177 | std::unique_lock<butil::Mutex> mu(_map_mutex); |
| 178 | if (_status != STOPPING && _status != RUNNING) { // no need to join. |
| 179 | return; |
| 180 | } |
| 181 | // `_listened_fd' will be set to -1 once it has been recycled |
| 182 | while (_listened_fd > 0 || !_socket_map.empty()) { |
| 183 | _empty_cond.Wait(); |
| 184 | } |
| 185 | const int saved_idle_timeout_sec = _idle_timeout_sec; |
| 186 | _idle_timeout_sec = 0; |
| 187 | const bthread_t saved_close_idle_tid = _close_idle_tid; |
| 188 | mu.unlock(); |
| 189 | |
| 190 | // Join the bthread outside lock. |
| 191 | if (saved_idle_timeout_sec > 0) { |
| 192 | bthread_stop(saved_close_idle_tid); |
| 193 | bthread_join(saved_close_idle_tid, NULL); |
| 194 | } |
| 195 | |
| 196 | { |
| 197 | BAIDU_SCOPED_LOCK(_map_mutex); |
| 198 | _status = READY; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | size_t Acceptor::ConnectionCount() const { |
| 203 | // Notice that _socket_map may be modified concurrently. This actually |
nothing calls this directly
no test coverage detected