aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/sockpool.cpp
diff options
context:
space:
mode:
authorand42 <and42@yandex-team.ru>2022-02-10 16:47:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:12 +0300
commit4fc9a1a64db469cc94894abfec740aa5c9e9789b (patch)
tree525f0b4c196e68c46ae8411cddc11211ef5670c1 /library/cpp/coroutine/engine/sockpool.cpp
parent287d7d8c4ffc811d1e51c756ecfb13b78f4ee62d (diff)
downloadydb-4fc9a1a64db469cc94894abfec740aa5c9e9789b.tar.gz
Restoring authorship annotation for <and42@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/coroutine/engine/sockpool.cpp')
-rw-r--r--library/cpp/coroutine/engine/sockpool.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/coroutine/engine/sockpool.cpp b/library/cpp/coroutine/engine/sockpool.cpp
index b9482e780f..01f8c35a4d 100644
--- a/library/cpp/coroutine/engine/sockpool.cpp
+++ b/library/cpp/coroutine/engine/sockpool.cpp
@@ -1,58 +1,58 @@
-#include "sockpool.h"
-
-void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa) {
- SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
-
- if (!sa || sa->sa_family == AF_INET) {
- sockaddr_in s_in;
- s_in.sin_family = AF_INET;
- s_in.sin_addr.s_addr = INADDR_ANY;
- s_in.sin_port = 0;
-
- if (bind(sock, (struct sockaddr*)&s_in, sizeof(s_in)) == -1) {
- warn("bind");
- }
- } else if (sa->sa_family == AF_INET6) {
+#include "sockpool.h"
+
+void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa) {
+ SetSockOpt(sock, SOL_SOCKET, SO_REUSEADDR, 1);
+
+ if (!sa || sa->sa_family == AF_INET) {
+ sockaddr_in s_in;
+ s_in.sin_family = AF_INET;
+ s_in.sin_addr.s_addr = INADDR_ANY;
+ s_in.sin_port = 0;
+
+ if (bind(sock, (struct sockaddr*)&s_in, sizeof(s_in)) == -1) {
+ warn("bind");
+ }
+ } else if (sa->sa_family == AF_INET6) {
sockaddr_in6 s_in6(*(const sockaddr_in6*)sa);
- Zero(s_in6.sin6_addr);
- s_in6.sin6_port = 0;
-
- if (bind(sock, (const struct sockaddr*)&s_in6, sizeof s_in6) == -1) {
- warn("bind6");
- }
- } else {
+ Zero(s_in6.sin6_addr);
+ s_in6.sin6_port = 0;
+
+ if (bind(sock, (const struct sockaddr*)&s_in6, sizeof s_in6) == -1) {
+ warn("bind6");
+ }
+ } else {
Y_ASSERT(0);
- }
-
- SetNoDelay(sock, true);
-}
-
-TPooledSocket TSocketPool::AllocateMore(TConnectData* conn) {
- TCont* cont = conn->Cont;
-
- while (true) {
+ }
+
+ SetNoDelay(sock, true);
+}
+
+TPooledSocket TSocketPool::AllocateMore(TConnectData* conn) {
+ TCont* cont = conn->Cont;
+
+ while (true) {
TSocketHolder s(NCoro::Socket(Addr_->Addr()->sa_family, SOCK_STREAM, 0));
-
- if (s == INVALID_SOCKET) {
+
+ if (s == INVALID_SOCKET) {
ythrow TSystemError(errno) << TStringBuf("can not create socket");
- }
-
- SetCommonSockOpts(s, Addr_->Addr());
- SetZeroLinger(s);
-
+ }
+
+ SetCommonSockOpts(s, Addr_->Addr());
+ SetZeroLinger(s);
+
const int ret = NCoro::ConnectD(cont, s, Addr_->Addr(), Addr_->Len(), conn->DeadLine);
-
- if (ret == EINTR) {
- continue;
- } else if (ret) {
+
+ if (ret == EINTR) {
+ continue;
+ } else if (ret) {
ythrow TSystemError(ret) << TStringBuf("can not connect(") << cont->Name() << ')';
- }
-
- THolder<TPooledSocket::TImpl> res(new TPooledSocket::TImpl(s, this));
- s.Release();
-
- if (res->IsOpen()) {
- return res.Release();
- }
- }
-}
+ }
+
+ THolder<TPooledSocket::TImpl> res(new TPooledSocket::TImpl(s, this));
+ s.Release();
+
+ if (res->IsOpen()) {
+ return res.Release();
+ }
+ }
+}