mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-24 16:52:24 +00:00
Windows dputs: use WriteFile to avoid stdio buffering.
Trying to debug a problem involving threads just now, it turned out that the version of the diagnostics going to my debug.log was getting data in a different order from the version going to the debug console. Now I open and write to debug_fp by going directly to the Win32 API instead of via a buffering userland stdio, and that seems to have solved the problem.
This commit is contained in:
parent
a73aaf9457
commit
1541974564
@ -11,7 +11,7 @@
|
|||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
static FILE *debug_fp = NULL;
|
static HANDLE debug_fp = INVALID_HANDLE_VALUE;
|
||||||
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
|
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
|
||||||
static int debug_got_console = 0;
|
static int debug_got_console = 0;
|
||||||
|
|
||||||
@ -25,13 +25,15 @@ void dputs(const char *buf)
|
|||||||
debug_hdl = GetStdHandle(STD_OUTPUT_HANDLE);
|
debug_hdl = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!debug_fp) {
|
if (debug_fp == INVALID_HANDLE_VALUE) {
|
||||||
debug_fp = fopen("debug.log", "w");
|
debug_fp = CreateFile("debug.log", GENERIC_WRITE, FILE_SHARE_READ,
|
||||||
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug_fp != INVALID_HANDLE_VALUE) {
|
||||||
|
WriteFile(debug_fp, buf, strlen(buf), &dw, NULL);
|
||||||
|
}
|
||||||
if (debug_hdl != INVALID_HANDLE_VALUE) {
|
if (debug_hdl != INVALID_HANDLE_VALUE) {
|
||||||
WriteFile(debug_hdl, buf, strlen(buf), &dw, NULL);
|
WriteFile(debug_hdl, buf, strlen(buf), &dw, NULL);
|
||||||
}
|
}
|
||||||
fputs(buf, debug_fp);
|
|
||||||
fflush(debug_fp);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user