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

Method IncreaseSendBuff

library/cpp/netliba/socket/socket.cpp:404–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402 }
403
404 bool TAbstractSocket::IncreaseSendBuff() {
405 int buffSize;
406 socklen_t sz = sizeof(buffSize);
407 if (GetSockOpt(SOL_SOCKET, SO_SNDBUF, &buffSize, &sz)) {
408 return false;
409 }
410 // worst case: 200000 pps * 8k * 0.01sec = 16Mb so 32Mb hard limit is reasonable value
411 if (buffSize < 0 || buffSize > (1 << 25)) {
412 fprintf(stderr, "GetSockOpt returns wrong or too big value for SO_SNDBUF: %d\n", buffSize);
413 return false;
414 }
415 //linux returns the doubled value. man 7 socket:
416 //
417 // SO_SNDBUF
418 // Sets or gets the maximum socket send buffer in bytes. The ker-
419 // nel doubles this value (to allow space for bookkeeping overhead)
420 // when it is set using setsockopt(), and this doubled value is
421 // returned by getsockopt(). The default value is set by the
422 // wmem_default sysctl and the maximum allowed value is set by the
423 // wmem_max sysctl. The minimum (doubled) value for this option is
424 // 2048.
425 //
426#ifndef _linux_
427 buffSize += buffSize;
428#endif
429
430 // false if previous value was less than current value.
431 // It means setsockopt was not successful. (for example: system limits)
432 // we will try to set it again but return false
433 const bool rv = !(buffSize <= SendSysSocketSizePrev);
434 if (SetSockOpt(SOL_SOCKET, SO_SNDBUF, &buffSize, sz) == 0) {
435 SendSysSocketSize = buffSize;
436 SendSysSocketSizePrev = buffSize;
437 return rv;
438 }
439 return false;
440 }
441
442 int TAbstractSocket::GetSendSysSocketSize() {
443 return SendSysSocketSize;

Callers 1

FlushPacketsMethod · 0.80

Calls 2

GetSockOptFunction · 0.85
SetSockOptFunction · 0.85

Tested by

no test coverage detected