diff options
author | Micael Karlberg <[email protected]> | 2019-07-04 14:51:28 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-07-04 14:51:28 +0200 |
commit | 40bf3831e0aae6d77cdcdbcc96fa916c22233c96 (patch) | |
tree | fb88f4b57d3b962980d0ba015feca1156c4054fa /erts | |
parent | 6801adfbe71a633b1e36a8981bfa7001ff476607 (diff) | |
download | otp-40bf3831e0aae6d77cdcdbcc96fa916c22233c96.tar.gz otp-40bf3831e0aae6d77cdcdbcc96fa916c22233c96.tar.bz2 otp-40bf3831e0aae6d77cdcdbcc96fa916c22233c96.zip |
[esock] Fixed debug "file"
Debug printouts is done to "dbgout", but the dbg macro
flushed "stdout" (which was the default). So, in order
to make the macro work properly in all cases, we rename
dbgout to esock_dbgout and make it extern (was static),
and then used that in the macro.
OTP-15817
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/nifs/common/socket_dbg.c | 16 | ||||
-rw-r--r-- | erts/emulator/nifs/common/socket_dbg.h | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/erts/emulator/nifs/common/socket_dbg.c b/erts/emulator/nifs/common/socket_dbg.c index 7dfc4b77bc..1180466c4c 100644 --- a/erts/emulator/nifs/common/socket_dbg.c +++ b/erts/emulator/nifs/common/socket_dbg.c @@ -37,23 +37,23 @@ #define TNAME(__T__) enif_thread_name( __T__ ) #define TSNAME() TNAME(TSELF()) -static FILE* dbgout = NULL; +FILE* esock_dbgout = NULL; extern void esock_dbg_init(char* filename) { if (filename != NULL) { if (strcmp(filename, ESOCK_DBGOUT_DEFAULT) == 0) { - dbgout = stdout; + esock_dbgout = stdout; } else if (strcmp(filename, ESOCK_DBGOUT_UNIQUE) == 0) { - char template[] = "/tmp/esock-dbg-XXXXXX"; - dbgout = fdopen(mkstemp(template), "w+"); + char template[] = "/tmp/esock-dbg-XXXXXX"; + esock_dbgout = fdopen(mkstemp(template), "w+"); } else { - dbgout = fopen(filename, "w+"); + esock_dbgout = fopen(filename, "w+"); } } else { char template[] = "/tmp/esock-dbg-XXXXXX"; - dbgout = fdopen(mkstemp(template), "w+"); + esock_dbgout = fdopen(mkstemp(template), "w+"); } } @@ -87,9 +87,9 @@ void esock_dbg_printf( const char* prefix, const char* format, ... ) if (res > 0) { va_start (args, format); - enif_vfprintf (dbgout, f, args); + enif_vfprintf (esock_dbgout, f, args); va_end (args); - fflush(dbgout); + fflush(esock_dbgout); } return; diff --git a/erts/emulator/nifs/common/socket_dbg.h b/erts/emulator/nifs/common/socket_dbg.h index 47739b46da..8fce211a8a 100644 --- a/erts/emulator/nifs/common/socket_dbg.h +++ b/erts/emulator/nifs/common/socket_dbg.h @@ -40,12 +40,12 @@ #endif typedef unsigned long long llu_t; - +extern FILE* esock_dbgout; // Initiated by the 'init' function #define ESOCK_DBG_PRINTF( ___COND___ , proto ) \ if ( ___COND___ ) { \ esock_dbg_printf proto; \ - fflush(stdout); \ + fflush(esock_dbgout); \ } |