testbot/testagentd: Fix the zero / infinite timeouts in the wait2 RPC.
Francois Gouget
fgouget at codeweavers.com
Tue Mar 26 07:12:53 CDT 2013
---
The Unix testagentd treated 0 as an infinite timeout while the Windows
one treated it as a 0s timeout. Now an infinite timeout is RUN_NOTIMEOUT
(0xffffffff) everywhere and 0 makes it possible to check whether a
process is still running without waiting.
testbot/lib/WineTestBot/TestAgent.pm | 2 +-
testbot/src/testagentd/platform.h | 2 ++
testbot/src/testagentd/platform_unix.c | 6 +++---
testbot/src/testagentd/platform_windows.c | 2 +-
testbot/src/testagentd/testagentd.c | 3 ++-
5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm
index 645a18c..bce1a78 100644
--- a/testbot/lib/WineTestBot/TestAgent.pm
+++ b/testbot/lib/WineTestBot/TestAgent.pm
@@ -1122,7 +1122,7 @@ sub Wait($$$)
if (!$self->_StartRPC($RPC_WAIT2) or
!$self->_SendListSize(2) or
!$self->_SendUInt64($Pid) or
- !$self->_SendUInt32($Timeout))
+ !$self->_SendUInt32(defined $Timeout ? $Timeout : 0xffffffff))
{
return undef;
}
diff --git a/testbot/src/testagentd/platform.h b/testbot/src/testagentd/platform.h
index 621ce98..fffaa4b 100644
--- a/testbot/src/testagentd/platform.h
+++ b/testbot/src/testagentd/platform.h
@@ -64,6 +64,8 @@ enum run_flags_t {
RUN_DNTRUNC_ERR = 4,
};
+#define RUN_NOTIMEOUT ((uint32_t)0xffffffff)
+
/* Starts the specified command in the background and reports the status to
* the client.
*/
diff --git a/testbot/src/testagentd/platform_unix.c b/testbot/src/testagentd/platform_unix.c
index 48eef73..e003135 100644
--- a/testbot/src/testagentd/platform_unix.c
+++ b/testbot/src/testagentd/platform_unix.c
@@ -154,7 +154,7 @@ int platform_wait(SOCKET client, uint64_t pid, uint32_t timeout, uint32_t *child
return 0;
}
- if (timeout)
+ if (timeout != RUN_NOTIMEOUT)
deadline = time(NULL) + timeout;
while (!child->reaped)
{
@@ -170,14 +170,14 @@ int platform_wait(SOCKET client, uint64_t pid, uint32_t timeout, uint32_t *child
debug("Waiting for " U64FMT "\n", pid);
FD_ZERO(&rfds);
FD_SET(client, &rfds);
- if (timeout)
+ if (timeout != RUN_NOTIMEOUT)
{
tv.tv_sec = deadline - time(NULL);
if (tv.tv_sec < 0)
tv.tv_sec = 0;
tv.tv_usec = 0;
}
- ready = select(client+1, &rfds, NULL, NULL, timeout ? &tv : NULL);
+ ready = select(client+1, &rfds, NULL, NULL, timeout != RUN_NOTIMEOUT ? &tv : NULL);
if (ready == 0)
{
/* This is the timeout */
diff --git a/testbot/src/testagentd/platform_windows.c b/testbot/src/testagentd/platform_windows.c
index 92fc9aa..a0dccfa 100644
--- a/testbot/src/testagentd/platform_windows.c
+++ b/testbot/src/testagentd/platform_windows.c
@@ -177,7 +177,7 @@ int platform_wait(SOCKET client, uint64_t pid, uint32_t timeout, uint32_t *child
handles[0] = WSACreateEvent();
WSAEventSelect(client, handles[0], FD_CLOSE);
handles[1] = child->handle;
- r = WaitForMultipleObjects(2, handles, FALSE, timeout * 1000);
+ r = WaitForMultipleObjects(2, handles, FALSE, timeout == RUN_NOTIMEOUT ? INFINITE : timeout * 1000);
success = 0;
switch (r)
diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c
index 534495d..75782c4 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -34,8 +34,9 @@
* 1.0: Initial release.
* 1.1: Added the wait2 RPC.
* 1.2: Add more redirection options to the run RPC.
+ * 1.3: Fix the zero / infinite timeouts in the wait2 RPC.
*/
-#define PROTOCOL_VERSION "testagentd 1.2"
+#define PROTOCOL_VERSION "testagentd 1.3"
#define BLOCK_SIZE 65536
--
1.7.10.4
More information about the wine-patches
mailing list