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

Method OnAccept

library/cpp/neh/tcp2.cpp:1523–1540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1521 }
1522
1523 void OnAccept(TTcpAcceptor* a, TTcpSocketRef s, const TErrorCode& ec, IHandlingContext&) {
1524 if (Y_UNLIKELY(ec)) {
1525 if (ec.Value() == ECANCELED) {
1526 return;
1527 } else if (ec.Value() == EMFILE || ec.Value() == ENFILE || ec.Value() == ENOMEM || ec.Value() == ENOBUFS) {
1528 //reach some os limit, suspend accepting for preventing busyloop (100% cpu usage)
1529 TSimpleSharedPtr<TDeadlineTimer> dt(new TDeadlineTimer(a->GetIOService()));
1530 dt->AsyncWaitExpireAt(TDuration::Seconds(30), std::bind(&TServer::OnTimeoutSuspendAccept, this, a, dt, _1, _2));
1531 } else {
1532 Cdbg << "acc: " << ec.Text() << Endl;
1533 }
1534 } else {
1535 SetNonBlock(s->Native());
1536 PrepareSocket(s->Native());
1537 TConnection::Create(*this, s);
1538 }
1539 StartAccept(a); //continue accepting
1540 }
1541
1542 void OnTimeoutSuspendAccept(TTcpAcceptor* a, TSimpleSharedPtr<TDeadlineTimer>, const TErrorCode& ec, IHandlingContext&) {
1543 if (!ec) {

Callers

nothing calls this directly

Calls 8

SetNonBlockFunction · 0.85
NativeMethod · 0.80
PrepareSocketFunction · 0.70
SecondsFunction · 0.50
CreateFunction · 0.50
ValueMethod · 0.45
AsyncWaitExpireAtMethod · 0.45
TextMethod · 0.45

Tested by

no test coverage detected