Skip to content

Commit

Permalink
Trying to fix the Windows build. Thank you Microsoft for making my li…
Browse files Browse the repository at this point in the history
…fe interesting!
  • Loading branch information
jgaa committed Apr 16, 2024
1 parent e036c0e commit 8a954bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(MYSQLPOOL_ROOT ${CMAKE_CURRENT_SOURCE_DIR})

if(WIN32)
add_compile_options(-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -DWIN32_LEAN_AND_MEAN=1)
endif()

message(STATUS "Using ${CMAKE_CXX_COMPILER}")

if (MYSQLPOOL_WITH_CONAN)
Expand Down
14 changes: 7 additions & 7 deletions include/mysqlpool/mysqlpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ T getFirstArgument(T first, ArgsT...) {

class Mysqlpool {
enum class ErrorMode {
IGNORE,
RETRY,
ALWAYS_FAIL
EM_IGNORE, // Cant use "IGNORE" as it clashes with one of Microsofts *many* cursed macros!
EM_RETRY,
EM_ALWAYS_FAIL
};


Expand Down Expand Up @@ -647,7 +647,7 @@ class Mysqlpool {
logQuery("close-stmt", query);
const auto [csec] = co_await connection().async_close_statement(*stmt, diag, tuple_awaitable);
if (sec) {
handleError(sec, diag, ErrorMode::IGNORE);
handleError(sec, diag, ErrorMode::EM_IGNORE);
}
connectionWrapper()->stmtCache().erase(query);
}
Expand Down Expand Up @@ -717,9 +717,9 @@ class Mysqlpool {
ErrorMode errorMode(const Options& opts) const noexcept {
if (opts.reconnect_and_retry_query) {
assert(!has_transaction_);
return ErrorMode::RETRY;
return ErrorMode::EM_RETRY;
}
return ErrorMode::ALWAYS_FAIL;
return ErrorMode::EM_ALWAYS_FAIL;
}

void commitAndReleaseLater() noexcept {
Expand Down Expand Up @@ -885,7 +885,7 @@ class Mysqlpool {
// If it returns false, connection to server is closed
static bool handleError(const boost::system::error_code& ec,
boost::mysql::diagnostics& diag,
ErrorMode mode = ErrorMode::ALWAYS_FAIL);
ErrorMode mode = ErrorMode::EM_ALWAYS_FAIL);


void startTimer();
Expand Down
4 changes: 2 additions & 2 deletions src/mysqlpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool Mysqlpool::handleError(const boost::system::error_code &ec, boost::mysql::d
<< "). Client: " << diag.client_message()
<< ". Server: " << diag.server_message());

if (em == ErrorMode::IGNORE) {
if (em == ErrorMode::EM_IGNORE) {
MYSQLPOOL_LOG_DEBUG_("Ignoring the error...");
return false;
}
Expand All @@ -230,7 +230,7 @@ bool Mysqlpool::handleError(const boost::system::error_code &ec, boost::mysql::d
case boost::system::errc::connection_reset:
case boost::system::errc::connection_aborted:
case boost::asio::error::operation_aborted:
if (em == ErrorMode::RETRY) {
if (em == ErrorMode::EM_RETRY) {
MYSQLPOOL_LOG_DEBUG_("The error is recoverable if we re-try the query it may succeed...");
return false; // retry
}
Expand Down

0 comments on commit 8a954bb

Please sign in to comment.