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

Method OnReadSome

library/cpp/neh/tcp2.cpp:1238–1278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236 }
1237
1238 void OnReadSome(const TErrorCode& ec, size_t amount, IHandlingContext& ctx) {
1239 while (1) {
1240 if (ec || !amount) {
1241 OnError();
1242 return;
1243 }
1244
1245 try {
1246 const char* buff = Buff_.Get();
1247 size_t leftBytes = amount;
1248 do {
1249 size_t useBytes = Msg_.LoadFrom(buff, leftBytes);
1250 leftBytes -= useBytes;
1251 buff += useBytes;
1252 if (Msg_.IsComplete()) {
1253 OnReceiveMessage();
1254 }
1255 } while (leftBytes);
1256
1257 if (amount == BuffSize_) {
1258 //try decrease system calls, - re-run ReadSome if has full filled buffer
1259 TErrorCode ecR;
1260 amount = AS_->ReadSome(Buff_.Get(), BuffSize_, ecR);
1261 if (!ecR) {
1262 continue;
1263 }
1264 if (ecR.Value() == EAGAIN || ecR.Value() == EWOULDBLOCK) {
1265 ctx.ContinueUseHandler();
1266 } else {
1267 OnError();
1268 }
1269 } else {
1270 ctx.ContinueUseHandler();
1271 }
1272 } catch (...) {
1273 DBGOUT("exc. " << CurrentExceptionMessage());
1274 OnError();
1275 }
1276 return;
1277 }
1278 }
1279
1280 void OnReceiveMessage() {
1281 DBGOUT("OnReceiveMessage()");

Callers

nothing calls this directly

Calls 7

CurrentExceptionMessageFunction · 0.85
LoadFromMethod · 0.80
ContinueUseHandlerMethod · 0.80
GetMethod · 0.45
IsCompleteMethod · 0.45
ReadSomeMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected