diff options
author | B. Stack <bgstack15@gmail.com> | 2024-06-23 16:51:52 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2024-06-23 16:51:52 -0400 |
commit | 994ec9e1cba547bed6eef02f996ca2a7beaf777a (patch) | |
tree | c6bdfb8c2096a1c579d3603e050d5f697d2306e0 /zen | |
parent | add upstream 13.6 (diff) | |
download | FreeFileSync-994ec9e1cba547bed6eef02f996ca2a7beaf777a.tar.gz FreeFileSync-994ec9e1cba547bed6eef02f996ca2a7beaf777a.tar.bz2 FreeFileSync-994ec9e1cba547bed6eef02f996ca2a7beaf777a.zip |
add upstream 13.713.7
Diffstat (limited to 'zen')
-rw-r--r-- | zen/error_log.h | 14 | ||||
-rw-r--r-- | zen/file_access.h | 2 | ||||
-rw-r--r-- | zen/format_unit.h | 2 | ||||
-rw-r--r-- | zen/socket.h | 29 | ||||
-rw-r--r-- | zen/type_traits.h | 1 |
5 files changed, 27 insertions, 21 deletions
diff --git a/zen/error_log.h b/zen/error_log.h index ff630cb8..2e5c4eb0 100644 --- a/zen/error_log.h +++ b/zen/error_log.h @@ -38,9 +38,9 @@ void logMsg(ErrorLog& log, const std::wstring& msg, MessageType type, time_t tim struct ErrorLogStats { - int info = 0; - int warning = 0; - int error = 0; + int infos = 0; + int warnings = 0; + int errors = 0; }; ErrorLogStats getStats(const ErrorLog& log); @@ -66,16 +66,16 @@ ErrorLogStats getStats(const ErrorLog& log) switch (entry.type) { case MSG_TYPE_INFO: - ++count.info; + ++count.infos; break; case MSG_TYPE_WARNING: - ++count.warning; + ++count.warnings; break; case MSG_TYPE_ERROR: - ++count.error; + ++count.errors; break; } - assert(std::ssize(log) == count.info + count.warning + count.error); + assert(std::ssize(log) == count.infos + count.warnings + count.errors); return count; } diff --git a/zen/file_access.h b/zen/file_access.h index 42cf1a46..a3fdcd70 100644 --- a/zen/file_access.h +++ b/zen/file_access.h @@ -24,7 +24,7 @@ const int FAT_FILE_TIME_PRECISION_SEC = 2; //https://devblogs.microsoft.com/oldn using FileIndex = ino_t; using FileTimeNative = timespec; -inline time_t nativeFileTimeToTimeT(const timespec& ft) { return ft.tv_sec; } //follow Windows Explorer: always round down! +inline time_t nativeFileTimeToTimeT(const timespec& ft) { return ft.tv_sec; } //follow File Explorer: always round down! inline timespec timetToNativeFileTime(time_t utcTime) { return {.tv_sec = utcTime}; } enum class ItemType diff --git a/zen/format_unit.h b/zen/format_unit.h index d7321a97..6a8f6b7b 100644 --- a/zen/format_unit.h +++ b/zen/format_unit.h @@ -17,7 +17,7 @@ namespace zen std::wstring formatFilesizeShort(int64_t filesize); std::wstring formatRemainingTime(double timeInSec); std::wstring formatProgressPercent(double fraction /*[0, 1]*/, int decPlaces = 0 /*[0, 9]*/); //rounded down! -std::wstring formatUtcToLocalTime(time_t utcTime); //like Windows Explorer would... +std::wstring formatUtcToLocalTime(time_t utcTime); //like File Explorer would... std::wstring formatTwoDigitPrecision (double value); //format with fixed number of digits std::wstring formatThreeDigitPrecision(double value); //(unless value is too large) diff --git a/zen/socket.h b/zen/socket.h index 0a311d01..461226d0 100644 --- a/zen/socket.h +++ b/zen/socket.h @@ -141,16 +141,6 @@ public: } setNonBlocking(testSocket, false); //throw SysError - //----------------------------------------------------------- - - int noDelay = 1; //disable Nagle algorithm: https://brooker.co.za/blog/2024/05/09/nagle.html - //e.g. test case "website sync": 23% shorter comparison time! - if (::setsockopt(testSocket, //_In_ SOCKET s - IPPROTO_TCP, //_In_ int level - TCP_NODELAY, //_In_ int optname - reinterpret_cast<char*>(&noDelay), //_In_ const char* optval - sizeof(noDelay)) != 0) //_In_ int optlen - THROW_LAST_SYS_ERROR_WSA("setsockopt(TCP_NODELAY)"); return testSocket; }; @@ -163,11 +153,26 @@ public: try { socket_ = getConnectedSocket(*si); //throw SysError; pass ownership - return; + firstError = std::nullopt; + break; } catch (const SysError& e) { if (!firstError) firstError = e; } - throw* firstError; //list was not empty, so there must have been an error! + if (firstError) + throw* firstError; + assert(socket_ != invalidSocket); //list was non-empty, so there's either an error, or a valid socket + ZEN_ON_SCOPE_FAIL(closeSocket(socket_)); + //----------------------------------------------------------- + //configure *after* selecting appropriate socket: cfg-failure should not discard otherwise fine connection! + + int noDelay = 1; //disable Nagle algorithm: https://brooker.co.za/blog/2024/05/09/nagle.html + //e.g. test case "website sync": 23% shorter comparison time! + if (::setsockopt(socket_, //_In_ SOCKET s + IPPROTO_TCP, //_In_ int level + TCP_NODELAY, //_In_ int optname + reinterpret_cast<const char*>(&noDelay), //_In_ const char* optval + sizeof(noDelay)) != 0) //_In_ int optlen + THROW_LAST_SYS_ERROR_WSA("setsockopt(TCP_NODELAY)"); } ~Socket() { closeSocket(socket_); } diff --git a/zen/type_traits.h b/zen/type_traits.h index 6186a2ae..e373ba07 100644 --- a/zen/type_traits.h +++ b/zen/type_traits.h @@ -30,6 +30,7 @@ public: using Type = decltype(dummyFun(F())); }; template <class F> using FunctionReturnTypeT = typename FunctionReturnType<F>::Type; +//yes, there's std::invoke_result_t, but it requires to specify function argument types for no good reason //============================================================================= |