[PATCH xorg-gtest] Deprecate WaitForConnections()

Peter Hutterer peter.hutterer at who-t.net
Wed Oct 3 22:55:34 PDT 2012


From: Daniel Martin <consume.noise at gmail.com>

As we already know that the XServer is ready for connections due to it's
notification via SIGUSR1, we don't need to poll anymore.

This only deprecates the call and warns potential users, it will be removed
in a future release.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Daniel, I'll merge this one instead of your complete removal. This gives us
more time to remove the call in the clients. We can completely remove it in
a later version.

 include/xorg/gtest/xorg-gtest-xserver.h |  2 +-
 src/environment.cpp                     |  1 -
 src/xserver.cpp                         | 30 ------------------------------
 3 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
index 2e7ef13..90784e7 100644
--- a/include/xorg/gtest/xorg-gtest-xserver.h
+++ b/include/xorg/gtest/xorg-gtest-xserver.h
@@ -109,7 +109,7 @@ class XServer : public xorg::testing::Process {
     /**
      * Waits until this server is ready to take connections.
      */
-    void WaitForConnections(void);
+    _X_DEPRECATED void WaitForConnections(void);
 
     /**
      * Set the display number for this server. This number must be set
diff --git a/src/environment.cpp b/src/environment.cpp
index 54eb6b6..44d6b2e 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -106,7 +106,6 @@ void xorg::testing::Environment::SetUp() {
   if (d_->path_to_conf.length())
     d_->server.SetOption("-config", d_->path_to_log_file);
   d_->server.Start(d_->path_to_server);
-  d_->server.WaitForConnections();
 
   Process::SetEnv("DISPLAY", d_->server.GetDisplayString(), true);
 }
diff --git a/src/xserver.cpp b/src/xserver.cpp
index 2ff718d..082818c 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -222,36 +222,6 @@ bool xorg::testing::XServer::WaitForDevice(::Display *display, const std::string
 }
 
 void xorg::testing::XServer::WaitForConnections(void) {
-  for (int i = 0; i < 100; ++i) {
-    Display *test_display = XOpenDisplay(GetDisplayString().c_str());
-
-    if (test_display) {
-      XCloseDisplay(test_display);
-      return;
-    }
-
-    int status;
-    int pid = waitpid(Pid(), &status, WNOHANG);
-    if (pid == Pid()) {
-      std::string message;
-      message += "X server failed to start on display ";
-      message +=  GetDisplayString();
-      message += ". Ensure that the correct video driver is installed.\n"
-                 "If the X.org server is older than 1.12, "
-                 "tests will need to be run as root.\nCheck ";
-      message += d_->options["-logfile"];
-      message += " for any errors";
-      throw std::runtime_error(message);
-    } else if (pid == 0) {
-      usleep(100);
-    } else if (pid == -1) {
-      throw std::runtime_error("Could not get status of X server process");
-    } else {
-      throw std::runtime_error("Invalid child PID returned by Process::Wait()");
-    }
-  }
-
-  throw std::runtime_error("Unable to open connection to X server");
 }
 
 void xorg::testing::XServer::TestStartup(void) {
-- 
1.7.11.4



More information about the xorg-devel mailing list