Alexandre Julliard : user32/tests: Protect the global message sequence with a critical section.
Alexandre Julliard
julliard at winehq.org
Tue Jan 14 13:44:59 CST 2014
Module: wine
Branch: master
Commit: 70009d053c803ecdc7a3d54d14003b68a5d1fb28
URL: http://source.winehq.org/git/wine.git/?a=commit;h=70009d053c803ecdc7a3d54d14003b68a5d1fb28
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Jan 14 13:31:10 2014 +0100
user32/tests: Protect the global message sequence with a critical section.
---
dlls/user32/tests/msg.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index f9398ee..dffaa8d 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -1723,6 +1723,7 @@ static BOOL after_end_dialog, test_def_id, paint_loop_done;
static int sequence_cnt, sequence_size;
static struct recvd_message* sequence;
static int log_all_parent_messages;
+static CRITICAL_SECTION sequence_cs;
/* user32 functions */
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
@@ -1813,7 +1814,8 @@ static void add_message_(int line, const struct recvd_message *msg)
{
struct recvd_message *seq;
- if (!sequence)
+ EnterCriticalSection( &sequence_cs );
+ if (!sequence)
{
sequence_size = 10;
sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
@@ -1825,7 +1827,7 @@ static void add_message_(int line, const struct recvd_message *msg)
}
assert(sequence);
- seq = &sequence[sequence_cnt];
+ seq = &sequence[sequence_cnt++];
seq->hwnd = msg->hwnd;
seq->message = msg->message;
seq->flags = msg->flags;
@@ -1834,6 +1836,7 @@ static void add_message_(int line, const struct recvd_message *msg)
seq->line = line;
seq->descr = msg->descr;
seq->output[0] = 0;
+ LeaveCriticalSection( &sequence_cs );
if (msg->descr)
{
@@ -1918,8 +1921,6 @@ static void add_message_(int line, const struct recvd_message *msg)
sprintf( seq->output + strlen(seq->output), " (flags %x)", msg->flags );
}
}
-
- sequence_cnt++;
}
/* try to make sure pending X events have been processed before continuing */
@@ -1940,9 +1941,11 @@ static void flush_events(void)
static void flush_sequence(void)
{
+ EnterCriticalSection( &sequence_cs );
HeapFree(GetProcessHeap(), 0, sequence);
sequence = 0;
sequence_cnt = sequence_size = 0;
+ LeaveCriticalSection( &sequence_cs );
}
static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
@@ -14290,6 +14293,7 @@ START_TEST(msg)
return;
}
+ InitializeCriticalSection( &sequence_cs );
init_procs();
hModuleImm32 = LoadLibraryA("imm32.dll");
@@ -14402,4 +14406,5 @@ START_TEST(msg)
GetLastError() == 0xdeadbeef, /* Win9x */
"unexpected error %d\n", GetLastError());
}
+ DeleteCriticalSection( &sequence_cs );
}
More information about the wine-cvs
mailing list