[Spice-devel] [PATCH spice-xpi 2/2] controller: return immediately if already connected

Christophe Fergeau cfergeau at redhat.com
Thu Mar 13 10:03:31 PDT 2014


On Fri, Mar 07, 2014 at 03:02:41PM +0100, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre.lureau at gmail.com>
> 
> Do not try again if the unix socket is already connected, but fail
> immediately.

Does that prevent a crash? Or what does this commit change from a end-user
perspective?

Christophe

> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1073461
> ---
>  SpiceXPI/src/plugin/controller-unix.cpp | 2 ++
>  SpiceXPI/src/plugin/controller.cpp      | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/SpiceXPI/src/plugin/controller-unix.cpp b/SpiceXPI/src/plugin/controller-unix.cpp
> index 1e60e5c..952f95c 100644
> --- a/SpiceXPI/src/plugin/controller-unix.cpp
> +++ b/SpiceXPI/src/plugin/controller-unix.cpp
> @@ -103,6 +103,8 @@ int SpiceControllerUnix::Connect()
>      int rc = connect(m_client_socket, (struct sockaddr *) &remote, strlen(remote.sun_path) + sizeof(remote.sun_family));
>      if (rc == -1)
>      {
> +        if (errno == EISCONN)
> +            rc = 1;
>          g_critical("controller connect: %s", g_strerror(errno));
>      }
>      else
> diff --git a/SpiceXPI/src/plugin/controller.cpp b/SpiceXPI/src/plugin/controller.cpp
> index bdfcba8..be56a28 100644
> --- a/SpiceXPI/src/plugin/controller.cpp
> +++ b/SpiceXPI/src/plugin/controller.cpp
> @@ -94,6 +94,8 @@ int SpiceController::Connect(const int nRetries)
>      for (int i = 0; rc != 0 && i < nRetries; ++i)
>      {
>          rc = Connect();
> +        if (rc == 1)
> +            break;
>          g_usleep(sleep_time * G_USEC_PER_SEC);
>      }
>      if (rc != 0) {
> -- 
> 1.8.5.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140313/f6a99feb/attachment.pgp>


More information about the Spice-devel mailing list