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

Method OnAccept

library/cpp/neh/http2.cpp:1894–1919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1892 }
1893
1894 void OnAccept(TTcpAcceptor* a, TAtomicSharedPtr<TTcpSocket> s, const TErrorCode& ec, IHandlingContext&) {
1895 if (Y_UNLIKELY(ec)) {
1896 if (ec.Value() == ECANCELED) {
1897 return;
1898 } else if (ec.Value() == EMFILE || ec.Value() == ENFILE || ec.Value() == ENOMEM || ec.Value() == ENOBUFS) {
1899 //reach some os limit, suspend accepting
1900 TAtomicSharedPtr<TDeadlineTimer> dt(new TDeadlineTimer(a->GetIOService()));
1901 dt->AsyncWaitExpireAt(TDuration::Seconds(30), std::bind(&THttpServer::OnTimeoutSuspendAccept, this, a, dt, _1, _2));
1902 return;
1903 } else {
1904 Cdbg << "acc: " << ec.Text() << Endl;
1905 }
1906 } else {
1907 if (static_cast<size_t>(HttpInConnCounter()->Val()) < HttpInConnLimits()->Hard()) {
1908 try {
1909 SetNonBlock(s->Native());
1910 PrepareSocket(s->Native());
1911 TConn::Create(*this, s);
1912 } catch (TSystemError& err) {
1913 TErrorCode ec2(err.Status());
1914 Cdbg << "acc: " << ec2.Text() << Endl;
1915 }
1916 } //else accepted socket will be closed
1917 }
1918 StartAccept(a); //continue accepting
1919 }
1920
1921 void OnTimeoutSuspendAccept(TTcpAcceptor* a, TAtomicSharedPtr<TDeadlineTimer>, const TErrorCode& ec, IHandlingContext&) {
1922 if (!ec) {

Callers

nothing calls this directly

Calls 13

HttpInConnCounterFunction · 0.85
HttpInConnLimitsFunction · 0.85
SetNonBlockFunction · 0.85
HardMethod · 0.80
NativeMethod · 0.80
PrepareSocketFunction · 0.70
SecondsFunction · 0.50
CreateFunction · 0.50
ValueMethod · 0.45
AsyncWaitExpireAtMethod · 0.45
TextMethod · 0.45
ValMethod · 0.45

Tested by

no test coverage detected