aboutsummaryrefslogtreecommitdiffstats
path: root/util/network
diff options
context:
space:
mode:
authorsobols <sobols@yandex-team.ru>2022-02-07 18:19:09 +0300
committersobols <sobols@yandex-team.ru>2022-02-07 18:19:09 +0300
commit19935c21e7247b6826b690be5ef76ecb635f9a90 (patch)
tree75dab396ae16d4a0ce436b87adcb85785eb9f02a /util/network
parent1110808a9d39d4b808aef724c861a2e1a38d2a69 (diff)
downloadydb-19935c21e7247b6826b690be5ef76ecb635f9a90.tar.gz
[util] Add a wrapper around setsockopt(...SO_PRIORITY...)
Works on Linux only ref:a8e96f0b8612a3c9b10e4a6ece310cc27707bc67
Diffstat (limited to 'util/network')
-rw-r--r--util/network/socket.cpp9
-rw-r--r--util/network/socket.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index c1a42e849e..4f6e804346 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -423,6 +423,15 @@ void SetSocketToS(SOCKET s, int tos) {
SetSocketToS(s, &addr, tos);
}
+void SetSocketPriority(SOCKET s, int priority) {
+#if defined(SO_PRIORITY)
+ CheckedSetSockOpt(s, SOL_SOCKET, SO_PRIORITY, priority, "priority");
+#else
+ Y_UNUSED(s);
+ Y_UNUSED(priority);
+#endif
+}
+
bool HasLocalAddress(SOCKET socket) {
TOpaqueAddr localAddr;
if (getsockname(socket, localAddr.MutableAddr(), localAddr.LenPtr()) != 0) {
diff --git a/util/network/socket.h b/util/network/socket.h
index 357ad4079b..40c8648b40 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -116,6 +116,7 @@ void SetSocketToS(SOCKET s, int tos);
void SetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr, int tos);
int GetSocketToS(SOCKET s);
int GetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr);
+void SetSocketPriority(SOCKET s, int priority);
void SetTcpFastOpen(SOCKET s, int qlen);
/**
* Deprecated, consider using HasSocketDataToRead instead.