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

Function SetCommonSockOpts

library/cpp/coroutine/engine/sockpool.cpp:3–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "sockpool.h"
2
3void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa) {
4 SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
5
6 if (!sa || sa->sa_family == AF_INET) {
7 sockaddr_in s_in;
8 s_in.sin_family = AF_INET;
9 s_in.sin_addr.s_addr = INADDR_ANY;
10 s_in.sin_port = 0;
11
12 if (bind(sock, (struct sockaddr*)&s_in, sizeof(s_in)) == -1) {
13 warn("bind");
14 }
15 } else if (sa->sa_family == AF_INET6) {
16 sockaddr_in6 s_in6(*(const sockaddr_in6*)sa);
17 Zero(s_in6.sin6_addr);
18 s_in6.sin6_port = 0;
19
20 if (bind(sock, (const struct sockaddr*)&s_in6, sizeof s_in6) == -1) {
21 warn("bind6");
22 }
23 } else {
24 Y_ASSERT(0);
25 }
26
27 SetNoDelay(sock, true);
28}
29
30TPooledSocket TSocketPool::AllocateMore(TConnectData* conn) {
31 TCont* cont = conn->Cont;

Callers 1

AllocateMoreMethod · 0.85

Calls 4

SetSockOptFunction · 0.85
ZeroFunction · 0.85
SetNoDelayFunction · 0.85
warnFunction · 0.50

Tested by

no test coverage detected