MCPcopy Create free account
hub / github.com/catboost/catboost / Start

Method Start

library/cpp/http/server/http.cpp:207–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 }
206
207 bool Start() {
208 Poller.Reset(new TSocketPoller());
209 Connections.Reset(new TConnections(Poller.Get(), Options_));
210
211 // throws on error
212 TPipeHandle::Pipe(ListenWakeupReadFd, ListenWakeupWriteFd);
213
214 SetNonBlock(ListenWakeupWriteFd, true);
215 SetNonBlock(ListenWakeupReadFd, true);
216
217 Poller->WaitRead(ListenWakeupReadFd, &WakeupPollAble);
218
219 ErrorCode = 0;
220
221 std::function<void(TSocket)> callback = [&](TSocket socket) {
222 THolder<TListenSocket> ls(new TListenSocket(socket, this));
223 if (Options_.OneShotPoll) {
224 Poller->WaitReadOneShot(socket, static_cast<IPollAble*>(ls.Get()));
225 } else {
226 Poller->WaitRead(socket, static_cast<IPollAble*>(ls.Get()));
227 }
228 Reqs.PushBack(ls.Release());
229 };
230
231 bool addressesBound = TryToBindAddresses(Options_, &callback);
232 if (!addressesBound) {
233 SaveErrorCode();
234 return false;
235 }
236
237 Requests->Start(Options_.nThreads, Options_.MaxQueueSize);
238 FailRequests->Start(Options_.nFThreads, Options_.MaxFQueueSize);
239 Cb_->OnListenStart();
240
241 try {
242 RunningListeners_.store(Options_.nListenerThreads);
243 for (size_t i = 0; i < Options_.nListenerThreads; ++i) {
244 ListenThreads.push_back(MakeHolder<TThread>([this, threadNum = i]() {
245 ListenSocket(threadNum);
246 }));
247 ListenThreads.back()->Start();
248 }
249 } catch (const yexception&) {
250 SaveErrorCode();
251 return false;
252 }
253
254 return true;
255 }
256
257 void JoinListenerThreads() {
258 while (!ListenThreads.empty()) {

Callers

nothing calls this directly

Calls 14

SetNonBlockFunction · 0.85
TryToBindAddressesFunction · 0.85
SaveErrorCodeFunction · 0.85
WaitReadMethod · 0.80
WaitReadOneShotMethod · 0.80
OnListenStartMethod · 0.80
ResetMethod · 0.45
GetMethod · 0.45
PushBackMethod · 0.45
ReleaseMethod · 0.45
StartMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected