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

Method OnConnect

library/cpp/neh/tcp2.cpp:719–744  ·  view source on GitHub ↗

must be called only from asio thread

Source from the content-addressed store, hash-verified

717
718 //must be called only from asio thread
719 void OnConnect(const TErrorCode& ec, IHandlingContext&) {
720 DBGOUT("TConnect::OnConnect: " << ec.Value());
721 if (Y_UNLIKELY(ec)) {
722 if (ec.Value() == EIO) {
723 //try get more detail error info
724 char buf[1];
725 TErrorCode errConnect;
726 AS_.ReadSome(buf, 1, errConnect);
727 OnErrorCode(errConnect.Value() ? errConnect : ec);
728 } else {
729 OnErrorCode(ec);
730 }
731 } else {
732 try {
733 PrepareSocket(AS_.Native());
734 AtomicSet(State_, Connected);
735 AS_.AsyncPollRead(std::bind(&TConnection::OnCanRead, TConnectionRef(this), _1, _2));
736 if (OutputLock_.TryAcquire()) {
737 SendMessages(true);
738 return;
739 }
740 } catch (...) {
741 OnError(CurrentExceptionMessage());
742 }
743 }
744 }
745
746 //must be called only after succes aquiring output
747 void SendMessages(bool asioThread) {

Callers

nothing calls this directly

Calls 8

CurrentExceptionMessageFunction · 0.85
NativeMethod · 0.80
AsyncPollReadMethod · 0.80
PrepareSocketFunction · 0.70
AtomicSetFunction · 0.50
ValueMethod · 0.45
ReadSomeMethod · 0.45
TryAcquireMethod · 0.45

Tested by

no test coverage detected