aboutsummaryrefslogtreecommitdiffstats
path: root/util/network
diff options
context:
space:
mode:
Diffstat (limited to 'util/network')
-rw-r--r--util/network/socket.cpp28
-rw-r--r--util/network/socket_ut.cpp72
2 files changed, 50 insertions, 50 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 4f6e804346..cec676b032 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -538,19 +538,19 @@ ESocketReadStatus HasSocketDataToRead(SOCKET s) {
}
#if defined(_win_)
-static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
+static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
return writev(sock, iov, iovcnt);
-}
-#else
-static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
- struct msghdr message;
-
- Zero(message);
- message.msg_iov = const_cast<struct iovec*>(iov);
- message.msg_iovlen = iovcnt;
-
- return sendmsg(sock, &message, MSG_NOSIGNAL);
-}
+}
+#else
+static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) {
+ struct msghdr message;
+
+ Zero(message);
+ message.msg_iov = const_cast<struct iovec*>(iov);
+ message.msg_iovlen = iovcnt;
+
+ return sendmsg(sock, &message, MSG_NOSIGNAL);
+}
#endif
void TSocketHolder::Close() noexcept {
@@ -709,7 +709,7 @@ static inline SOCKET DoConnect(const struct addrinfo* res, const TInstant& deadL
static inline ssize_t DoSendV(SOCKET fd, const struct iovec* iov, size_t count) {
ssize_t ret = -1;
do {
- ret = DoSendMsg(fd, iov, (int)count);
+ ret = DoSendMsg(fd, iov, (int)count);
} while (ret == -1 && errno == EINTR);
if (ret < 0) {
@@ -760,7 +760,7 @@ public:
ssize_t Send(SOCKET fd, const void* data, size_t len) override {
ssize_t ret = -1;
do {
- ret = send(fd, (const char*)data, (int)len, MSG_NOSIGNAL);
+ ret = send(fd, (const char*)data, (int)len, MSG_NOSIGNAL);
} while (ret == -1 && errno == EINTR);
if (ret < 0) {
diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp
index 6b20e11f70..5980c7d370 100644
--- a/util/network/socket_ut.cpp
+++ b/util/network/socket_ut.cpp
@@ -1,7 +1,7 @@
#include "socket.h"
-#include "pair.h"
-
+#include "pair.h"
+
#include <library/cpp/testing/unittest/registar.h>
#include <util/string/builder.h>
@@ -23,7 +23,7 @@ class TSockTest: public TTestBase {
#endif
UNIT_TEST(TestNetworkResolutionError);
UNIT_TEST(TestNetworkResolutionErrorMessage);
- UNIT_TEST(TestBrokenPipe);
+ UNIT_TEST(TestBrokenPipe);
UNIT_TEST(TestClose);
UNIT_TEST(TestReusePortAvailCheck);
UNIT_TEST_SUITE_END();
@@ -34,7 +34,7 @@ public:
void TestConnectionRefused();
void TestNetworkResolutionError();
void TestNetworkResolutionErrorMessage();
- void TestBrokenPipe();
+ void TestBrokenPipe();
void TestClose();
void TestReusePortAvailCheck();
};
@@ -129,43 +129,43 @@ void TSockTest::TestNetworkResolutionErrorMessage() {
}
class TTempEnableSigPipe {
-public:
- TTempEnableSigPipe() {
+public:
+ TTempEnableSigPipe() {
OriginalSigHandler_ = signal(SIGPIPE, SIG_DFL);
Y_VERIFY(OriginalSigHandler_ != SIG_ERR);
- }
-
- ~TTempEnableSigPipe() {
+ }
+
+ ~TTempEnableSigPipe() {
auto ret = signal(SIGPIPE, OriginalSigHandler_);
- Y_VERIFY(ret != SIG_ERR);
- }
-
-private:
+ Y_VERIFY(ret != SIG_ERR);
+ }
+
+private:
void (*OriginalSigHandler_)(int);
-};
-
+};
+
void TSockTest::TestBrokenPipe() {
- TTempEnableSigPipe guard;
-
- SOCKET socks[2];
-
- int ret = SocketPair(socks);
- UNIT_ASSERT_VALUES_EQUAL(ret, 0);
-
- TSocket sender(socks[0]);
- TSocket receiver(socks[1]);
- receiver.ShutDown(SHUT_RDWR);
- int sent = sender.Send("FOO", 3);
- UNIT_ASSERT(sent < 0);
-
- IOutputStream::TPart parts[] = {
- {"foo", 3},
- {"bar", 3},
- };
- sent = sender.SendV(parts, 2);
- UNIT_ASSERT(sent < 0);
-}
-
+ TTempEnableSigPipe guard;
+
+ SOCKET socks[2];
+
+ int ret = SocketPair(socks);
+ UNIT_ASSERT_VALUES_EQUAL(ret, 0);
+
+ TSocket sender(socks[0]);
+ TSocket receiver(socks[1]);
+ receiver.ShutDown(SHUT_RDWR);
+ int sent = sender.Send("FOO", 3);
+ UNIT_ASSERT(sent < 0);
+
+ IOutputStream::TPart parts[] = {
+ {"foo", 3},
+ {"bar", 3},
+ };
+ sent = sender.SendV(parts, 2);
+ UNIT_ASSERT(sent < 0);
+}
+
void TSockTest::TestClose() {
SOCKET socks[2];