[PATCH spice-xpi] wait for a socket file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Or with some timeout hooked up.

---
 SpiceXPI/src/plugin/controller.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/SpiceXPI/src/plugin/controller.cpp b/SpiceXPI/src/plugin/controller.cpp
index b912c27..323e89a 100644
--- a/SpiceXPI/src/plugin/controller.cpp
+++ b/SpiceXPI/src/plugin/controller.cpp
@@ -51,6 +51,8 @@ extern "C" {
 #  include <unistd.h>
 #  include <fcntl.h>
 #  include <sys/socket.h>
+#  include <sys/types.h>
+#  include <sys/stat.h>
 #  include <sys/un.h>
 }
 
@@ -94,6 +96,12 @@ int SpiceController::Connect()
         }
     }
 
+    // wait for a socket file
+    struct stat buf;
+    int timeout = 30;
+    while (stat(m_name.c_str(), &buf) && timeout--)
+        usleep(100000);
+
     struct sockaddr_un remote;
     remote.sun_family = AF_UNIX;
     if (m_name.length() + 1 > sizeof(remote.sun_path))
-- 
Peter Hatina
EMEA ENG-Base Operating Systems
Red Hat Czech, Brno

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]