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

Method OnConnect

library/cpp/neh/http2.cpp:653–721  ·  view source on GitHub ↗

can be called only from asio

Source from the content-addressed store, hash-verified

651
652 //can be called only from asio
653 void OnConnect(const TErrorCode& ec, IHandlingContext& ctx) {
654 DBGOUT("THttpConn::OnConnect: " << ec.Value());
655 if (Y_UNLIKELY(ec)) {
656 if (ec.Value() == ETIMEDOUT && ConnectDeadline_.GetValue()) {
657 //detect slow connecting (yet not reached final timeout)
658 DBGOUT("OnConnectTimingCheck");
659 THttpRequestRef req(GetRequest());
660 if (!req) {
661 return; //cancel from client thread can ahead us
662 }
663 TDuration newDeadline(ConnectDeadline_);
664 ConnectDeadline_ = TDuration::Zero(); //next timeout is final
665
666 req->OnDetectSlowConnecting();
667 //continue wait connect
668 ctx.ContinueUseHandler(newDeadline);
669
670 return;
671 }
672#ifdef DEBUG_STAT
673 if (ec.Value() != ECANCELED) {
674 ++TDebugStat::ConnFailed;
675 } else {
676 ++TDebugStat::ConnConnCanceled;
677 }
678#endif
679 if (ec.Value() == EIO) {
680 //try get more detail error info
681 char buf[1];
682 TErrorCode errConnect;
683 AS_.ReadSome(buf, 1, errConnect);
684 OnConnectFailed(errConnect.Value() ? errConnect : ec);
685 } else if (ec.Value() == ECANCELED) {
686 // not try connecting to next host ip addr, simple fail
687 OnError(ec);
688 } else {
689 OnConnectFailed(ec);
690 }
691 } else {
692 Connected_ = true;
693
694 THttpRequestRef req(GetRequest());
695 if (!req || Canceled_) {
696 return;
697 }
698
699 try {
700 PrepareSocket(AS_.Native(), req->RequestSettings());
701 if (THttp2Options::TcpKeepAlive) {
702 SetKeepAlive(AS_.Native(), true);
703 }
704 } catch (TSystemError& err) {
705 TErrorCode ec2(err.Status());
706 OnError(ec2);
707 return;
708 }
709
710 req->OnConnect(this);

Callers

nothing calls this directly

Calls 13

ZeroFunction · 0.85
SetKeepAliveFunction · 0.85
ContinueUseHandlerMethod · 0.80
NativeMethod · 0.80
BuildRequestMethod · 0.80
PrepareSocketFunction · 0.70
ValueMethod · 0.45
GetValueMethod · 0.45
ReadSomeMethod · 0.45
RequestSettingsMethod · 0.45
StatusMethod · 0.45

Tested by

no test coverage detected