Skip to content

Fix log fd opening on windows #3076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/atomic_win32_polyfill.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#define atomic_fetch_sub(var, val) atomic_fetch_add(var, -(val))
#define atomic_fetch_or _InterlockedOr64
#define atomic_fetch_and _InterlockedAnd64
#define atomic_compare_exchange_strong(var, expected, val) _InterlockedCompareExchange64(var, *(expected), val)
#define atomic_compare_exchange_strong(var, expected, val) (_InterlockedCompareExchange64(var, val, *(expected)) == *(expected))
#define atomic_compare_exchange_strong_int(var, expected, val) (_InterlockedCompareExchange(var, val, *(expected)) == *(expected))

// "Simple reads and writes to properly aligned 64 bit [also 32 bit] variables are atomic on 64-bit windows"
#define atomic_store(var, val) (*var = val)
Expand Down
6 changes: 5 additions & 1 deletion ext/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "configuration.h"
#include <main/SAPI.h>

#ifndef _WIN32
#define atomic_compare_exchange_strong_int atomic_compare_exchange_strong
#endif


static void dd_log_set_level(bool debug) {
bool once = runtime_config_first_init ? get_DD_TRACE_ONCE_LOGS() : get_global_DD_TRACE_ONCE_LOGS();
Expand Down Expand Up @@ -83,7 +87,7 @@ void ddtrace_log_rinit(char *error_log) {
time(&now);
atomic_store(&dd_error_log_fd_rotated, (uintmax_t) now);
int expected = -1;
if (!atomic_compare_exchange_strong(&ddtrace_error_log_fd, &expected, desired)) {
if (!atomic_compare_exchange_strong_int(&ddtrace_error_log_fd, &expected, desired)) {
// if it didn't exchange, then we need to free it
close(desired);
}
Expand Down
Loading