[Spice-devel] [PATCH spice-xpi] wait for the socket file
Marc-André Lureau
mlureau at redhat.com
Tue Aug 7 03:04:32 PDT 2012
----- Mensaje original -----
> Hi,
>
> in a log (rhel) and also in the debug messages, there sometimes
> appear
> messages, that a controller could not connect to a socket file
> (int SpiceController::Connect()). This is caused by the fact, that we
> try
> to connect before the socket is present. I added this simple poll
> loop to
> wait for the socket file to be created.
>
> Any opinions?
There is already an outer loop doing connection retries. I don't see how this change is really an improvement except making the retry period longer.
Tbh, I think we should change the way the connection is done, the xpi should be the one to bind/listen imho, that would avoid that silly loop.
I might be missing something though.
nack without further details about why this is needed.
>
> ---
> SpiceXPI/src/plugin/controller.cpp | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/SpiceXPI/src/plugin/controller.cpp
> b/SpiceXPI/src/plugin/controller.cpp
> index b912c27..094f086 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,11 @@ int SpiceController::Connect()
> }
> }
>
> + // wait for a socket file
> + struct stat buf;
> + while (stat(m_name.c_str(), &buf))
> + 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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list