Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fotios Valasiadis
wine
Commits
db50578d
Commit
db50578d
authored
20 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Avoid killing threads with TerminateThread, this can cause deadlocks.
parent
47a88ba2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/kernel/tests/pipe.c
+21
-10
21 additions, 10 deletions
dlls/kernel/tests/pipe.c
with
21 additions
and
10 deletions
dlls/kernel/tests/pipe.c
+
21
−
10
View file @
db50578d
...
...
@@ -50,6 +50,10 @@
#define PIPENAME "\\\\.\\PiPe\\tests_" __FILE__
#define NB_SERVER_LOOPS 8
static
HANDLE
alarm_event
;
void
test_CreateNamedPipe
(
pipemode
)
{
HANDLE
hnp
;
...
...
@@ -384,9 +388,11 @@ static DWORD CALLBACK alarmThreadMain(LPVOID arg)
{
DWORD
timeout
=
(
DWORD
)
arg
;
trace
(
"alarmThreadMain
\n
"
);
Sleep
(
timeout
);
ok
(
FALSE
,
"alarm
\n
"
);
ExitProcess
(
1
);
if
(
WaitForSingleObject
(
alarm_event
,
timeout
)
==
WAIT_TIMEOUT
)
{
ok
(
FALSE
,
"alarm
\n
"
);
ExitProcess
(
1
);
}
return
1
;
}
...
...
@@ -408,7 +414,7 @@ static DWORD CALLBACK serverThreadMain1(LPVOID arg)
/* lpSecurityAttrib */
NULL
);
ok
(
hnp
!=
INVALID_HANDLE_VALUE
,
"CreateNamedPipe failed
\n
"
);
for
(
i
=
0
;
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_SERVER_LOOPS
;
i
++
)
{
char
buf
[
512
];
DWORD
written
;
DWORD
readden
;
...
...
@@ -440,6 +446,7 @@ static DWORD CALLBACK serverThreadMain1(LPVOID arg)
ok
(
DisconnectNamedPipe
(
hnp
),
"DisconnectNamedPipe
\n
"
);
trace
(
"Server done disconnecting.
\n
"
);
}
return
0
;
}
/** Trivial byte echo server - closes after each connection */
...
...
@@ -459,7 +466,7 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
/* lpSecurityAttrib */
NULL
);
ok
(
hnp
!=
INVALID_HANDLE_VALUE
,
"CreateNamedPipe failed
\n
"
);
for
(
i
=
0
;
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_SERVER_LOOPS
;
i
++
)
{
char
buf
[
512
];
DWORD
written
;
DWORD
readden
;
...
...
@@ -503,6 +510,7 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
ok
(
CloseHandle
(
hnp
),
"CloseHandle
\n
"
);
hnp
=
hnpNext
;
}
return
0
;
}
/** Trivial byte echo server - uses overlapped named pipe calls */
...
...
@@ -528,7 +536,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
NULL
);
/* name */
ok
(
hEvent
!=
NULL
,
"CreateEvent
\n
"
);
for
(
i
=
0
;
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_SERVER_LOOPS
;
i
++
)
{
char
buf
[
512
];
DWORD
written
;
DWORD
readden
;
...
...
@@ -599,6 +607,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
ok
(
FlushFileBuffers
(
hnp
),
"FlushFileBuffers
\n
"
);
ok
(
DisconnectNamedPipe
(
hnp
),
"DisconnectNamedPipe
\n
"
);
}
return
0
;
}
static
void
exercizeServer
(
const
char
*
pipename
,
HANDLE
serverThread
)
...
...
@@ -606,7 +615,7 @@ static void exercizeServer(const char *pipename, HANDLE serverThread)
int
i
;
trace
(
"exercizeServer starting
\n
"
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
NB_SERVER_LOOPS
;
i
++
)
{
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
const
char
obuf
[]
=
"Bit Bucket"
;
char
ibuf
[
32
];
...
...
@@ -646,7 +655,7 @@ static void exercizeServer(const char *pipename, HANDLE serverThread)
ok
(
CloseHandle
(
hFile
),
"CloseHandle
\n
"
);
}
ok
(
TerminateThread
(
serverThread
,
0
),
"TerminateThread
\n
"
);
ok
(
WaitForSingleObject
(
serverThread
,
INFINITE
)
==
WAIT_OBJECT_0
,
"WaitForSingleObject
\n
"
);
CloseHandle
(
hnp
);
trace
(
"exercizeServer returning
\n
"
);
}
...
...
@@ -660,6 +669,7 @@ void test_NamedPipe_2(void)
trace
(
"test_NamedPipe_2 starting
\n
"
);
/* Set up a ten second timeout */
alarm_event
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
alarmThread
=
CreateThread
(
NULL
,
0
,
alarmThreadMain
,
(
void
*
)
10000
,
0
,
&
alarmThreadId
);
/* The servers we're about to exercize do try to clean up carefully,
...
...
@@ -668,7 +678,7 @@ void test_NamedPipe_2(void)
*/
/* Try server #1 */
serverThread
=
CreateThread
(
NULL
,
0
,
serverThreadMain1
,
0
,
0
,
&
serverThreadId
);
serverThread
=
CreateThread
(
NULL
,
0
,
serverThreadMain1
,
(
void
*
)
8
,
0
,
&
serverThreadId
);
ok
(
serverThread
!=
INVALID_HANDLE_VALUE
,
"CreateThread
\n
"
);
exercizeServer
(
PIPENAME
"serverThreadMain1"
,
serverThread
);
...
...
@@ -685,7 +695,8 @@ void test_NamedPipe_2(void)
exercizeServer
(
PIPENAME
"serverThreadMain3"
,
serverThread
);
}
ok
(
TerminateThread
(
alarmThread
,
0
),
"TerminateThread
\n
"
);
ok
(
SetEvent
(
alarm_event
),
"SetEvent
\n
"
);
CloseHandle
(
alarm_event
);
trace
(
"test_NamedPipe_2 returning
\n
"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment