| 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) { |
nothing calls this directly
no test coverage detected