mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-27 13:14:26 -04:00
[misc] improve uprintf() concurrency by using a mutex
This commit is contained in:
parent
20b8a84595
commit
53b014781d
2 changed files with 13 additions and 5 deletions
|
@ -43,6 +43,7 @@
|
|||
HWND hStatus;
|
||||
size_t ubuffer_pos = 0;
|
||||
char ubuffer[UBUFFER_SIZE]; // Buffer for ubpushf() messages we don't log right away
|
||||
static HANDLE print_mutex = NULL;
|
||||
|
||||
void _uprintf(const char *format, ...)
|
||||
{
|
||||
|
@ -52,6 +53,11 @@ void _uprintf(const char *format, ...)
|
|||
va_list args;
|
||||
int n;
|
||||
|
||||
if (print_mutex == NULL)
|
||||
print_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||
if (WaitForSingleObject(print_mutex, INFINITE) != WAIT_OBJECT_0)
|
||||
return;
|
||||
|
||||
va_start(args, format);
|
||||
n = safe_vsnprintf(p, sizeof(buf)-3, format, args); // buf-3 is room for CR/LF/NUL
|
||||
va_end(args);
|
||||
|
@ -78,6 +84,8 @@ void _uprintf(const char *format, ...)
|
|||
Edit_Scroll(hLog, Edit_GetLineCount(hLog), 0);
|
||||
}
|
||||
free(wbuf);
|
||||
|
||||
ReleaseMutex(print_mutex);
|
||||
}
|
||||
|
||||
void _uprintfs(const char* str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue