Browse Source

Restoring authorship annotation for <nocomer@yandex-team.ru>. Commit 2 of 2.

nocomer 3 years ago
parent
commit
df2933eb0e
5 changed files with 43 additions and 43 deletions
  1. 11 11
      util/network/socket.cpp
  2. 10 10
      util/network/socket.h
  3. 1 1
      util/system/context.cpp
  4. 19 19
      util/system/sanitizers.cpp
  5. 2 2
      util/system/sanitizers.h

+ 11 - 11
util/network/socket.cpp

@@ -523,18 +523,18 @@ static int MsgPeek(SOCKET s) {
 }
 
 bool IsNotSocketClosedByOtherSide(SOCKET s) {
-    return HasSocketDataToRead(s) != ESocketReadStatus::SocketClosed; 
-} 
- 
-ESocketReadStatus HasSocketDataToRead(SOCKET s) { 
+    return HasSocketDataToRead(s) != ESocketReadStatus::SocketClosed;
+}
+
+ESocketReadStatus HasSocketDataToRead(SOCKET s) {
     const int r = MsgPeek(s);
-    if (r == -1 && IsBlocked(LastSystemError())) { 
-        return ESocketReadStatus::NoData; 
-    } 
-    if (r > 0) { 
-        return ESocketReadStatus::HasData; 
-    } 
-    return ESocketReadStatus::SocketClosed; 
+    if (r == -1 && IsBlocked(LastSystemError())) {
+        return ESocketReadStatus::NoData;
+    }
+    if (r > 0) {
+        return ESocketReadStatus::HasData;
+    }
+    return ESocketReadStatus::SocketClosed;
 }
 
 #if defined(_win_)

+ 10 - 10
util/network/socket.h

@@ -119,19 +119,19 @@ 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. 
+ * Deprecated, consider using HasSocketDataToRead instead.
  **/
 bool IsNotSocketClosedByOtherSide(SOCKET s);
-enum class ESocketReadStatus { 
-    HasData, 
-    NoData, 
-    SocketClosed 
-}; 
+enum class ESocketReadStatus {
+    HasData,
+    NoData,
+    SocketClosed
+};
+/**
+ * Useful for keep-alive connections.
+ **/
+ESocketReadStatus HasSocketDataToRead(SOCKET s);
 /**
- * Useful for keep-alive connections. 
- **/ 
-ESocketReadStatus HasSocketDataToRead(SOCKET s); 
-/** 
  * Determines whether connection on socket is local (same machine) or not.
  **/
 bool HasLocalAddress(SOCKET socket);

+ 1 - 1
util/system/context.cpp

@@ -197,7 +197,7 @@ TContMachineContext::TContMachineContext(const TContClosure& c)
 void TContMachineContext::SwitchTo(TContMachineContext* next) noexcept {
     if (Y_LIKELY(__mysetjmp(Buf_) == 0)) {
     #if defined(_asan_enabled_) || defined(_tsan_enabled_)
-        next->San_.BeforeSwitch(&San_); 
+        next->San_.BeforeSwitch(&San_);
     #endif
         __mylongjmp(next->Buf_, 1);
     } else {

+ 19 - 19
util/system/sanitizers.cpp

@@ -39,7 +39,7 @@ using namespace NSan;
 
 TFiberContext::TFiberContext() noexcept
     : Token_(nullptr)
-    , IsMainFiber_(true) 
+    , IsMainFiber_(true)
 #if defined(_tsan_enabled_)
     , CurrentTSanFiberContext_(__tsan_get_current_fiber())
 #endif
@@ -59,7 +59,7 @@ TFiberContext::TFiberContext(const void* stack, size_t len, const char* contName
     : Token_(nullptr)
     , Stack_(stack)
     , Len_(len)
-    , IsMainFiber_(false) 
+    , IsMainFiber_(false)
 #if defined(_tsan_enabled_)
     , CurrentTSanFiberContext_(__tsan_create_fiber(/*flags =*/0))
 #endif
@@ -71,22 +71,22 @@ TFiberContext::TFiberContext(const void* stack, size_t len, const char* contName
 }
 
 TFiberContext::~TFiberContext() noexcept {
-    if (!IsMainFiber_) { 
-#if defined(_asan_enabled_) 
-        if (Token_) { 
-            // destroy saved FakeStack 
-            void* activeFakeStack = nullptr; 
-            const void* activeStack = nullptr; 
-            size_t activeStackSize = 0; 
-            __sanitizer_start_switch_fiber(&activeFakeStack, (char*)Stack_, Len_); 
-            __sanitizer_finish_switch_fiber(Token_, &activeStack, &activeStackSize); 
-            __sanitizer_start_switch_fiber(nullptr, activeStack, activeStackSize); 
-            __sanitizer_finish_switch_fiber(activeFakeStack, nullptr, nullptr); 
-        } 
-#endif 
+    if (!IsMainFiber_) {
+#if defined(_asan_enabled_)
+        if (Token_) {
+            // destroy saved FakeStack
+            void* activeFakeStack = nullptr;
+            const void* activeStack = nullptr;
+            size_t activeStackSize = 0;
+            __sanitizer_start_switch_fiber(&activeFakeStack, (char*)Stack_, Len_);
+            __sanitizer_finish_switch_fiber(Token_, &activeStack, &activeStackSize);
+            __sanitizer_start_switch_fiber(nullptr, activeStack, activeStackSize);
+            __sanitizer_finish_switch_fiber(activeFakeStack, nullptr, nullptr);
+        }
+#endif
 #if defined(_tsan_enabled_)
         __tsan_destroy_fiber(CurrentTSanFiberContext_);
-#endif 
+#endif
     }
 }
 
@@ -100,11 +100,11 @@ void TFiberContext::BeforeFinish() noexcept {
 #endif
 }
 
-void TFiberContext::BeforeSwitch(TFiberContext* old) noexcept { 
+void TFiberContext::BeforeSwitch(TFiberContext* old) noexcept {
 #if defined(_asan_enabled_)
     __sanitizer_start_switch_fiber(old ? &old->Token_ : nullptr, (char*)Stack_, Len_);
-#else 
-    (void)old; 
+#else
+    (void)old;
 #endif
 
 #if defined(_tsan_enabled_)

+ 2 - 2
util/system/sanitizers.h

@@ -25,7 +25,7 @@ namespace NSan {
         ~TFiberContext() noexcept;
 
         void BeforeFinish() noexcept;
-        void BeforeSwitch(TFiberContext* old) noexcept; 
+        void BeforeSwitch(TFiberContext* old) noexcept;
         void AfterSwitch() noexcept;
 
         static void AfterStart() noexcept;
@@ -35,7 +35,7 @@ namespace NSan {
         const void* Stack_;
         size_t Len_;
 
-        const bool IsMainFiber_; 
+        const bool IsMainFiber_;
 #if defined(_tsan_enabled_)
         void* const CurrentTSanFiberContext_;
 #endif