[PATCH xorg-gtest 3/4] xserver: don't sleep for a second, 100us is enough

Peter Hutterer peter.hutterer at who-t.net
Mon Sep 24 17:34:55 PDT 2012


But loop more often. On my machine the average wait time for the server to
start up appears to be ~600 us. Play it safe, usleep for 100us only and then
try again.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xserver.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xserver.cpp b/src/xserver.cpp
index d371421..28f2eca 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -222,7 +222,7 @@ bool xorg::testing::XServer::WaitForDevice(::Display *display, const std::string
 }
 
 void xorg::testing::XServer::WaitForConnections(void) {
-  for (int i = 0; i < 10; ++i) {
+  for (int i = 0; i < 100; ++i) {
     Display *test_display = XOpenDisplay(GetDisplayString().c_str());
 
     if (test_display) {
@@ -243,7 +243,7 @@ void xorg::testing::XServer::WaitForConnections(void) {
       message += " for any errors";
       throw std::runtime_error(message);
     } else if (pid == 0) {
-      sleep(1); /* Give the X server some time to start */
+      usleep(100);
     } else if (pid == -1) {
       throw std::runtime_error("Could not get status of X server process");
     } else {
-- 
1.7.11.2



More information about the xorg-devel mailing list