MCPcopy Create free account
hub / github.com/apache/brpc / Join

Method Join

src/brpc/acceptor.cpp:176–200  ·  view source on GitHub ↗

NOTE: Join() can happen before StopAccept()

Source from the content-addressed store, hash-verified

174
175// NOTE: Join() can happen before StopAccept()
176void 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
202size_t Acceptor::ConnectionCount() const {
203 // Notice that _socket_map may be modified concurrently. This actually

Callers

nothing calls this directly

Calls 5

bthread_stopFunction · 0.85
bthread_joinFunction · 0.85
emptyMethod · 0.45
WaitMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected