[Spice-commits] 2 commits - SpiceXPI/src
Marc-André Lureau
elmarco at kemper.freedesktop.org
Tue Jun 3 08:46:06 PDT 2014
SpiceXPI/src/plugin/controller-unix.cpp | 2 ++
SpiceXPI/src/plugin/controller.cpp | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit ef04d6e88cd32f391aa620f723df3eddaa7d4751
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Fri Mar 7 14:59:20 2014 +0100
controller: return immediately if already connected
Do not try again if the unix socket is already connected, but fail
immediately.
https://bugzilla.redhat.com/show_bug.cgi?id=1073461
diff --git a/SpiceXPI/src/plugin/controller-unix.cpp b/SpiceXPI/src/plugin/controller-unix.cpp
index d9bf9a5..83dc59a 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 988768b..bd8b9d7 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) {
commit 453f0deb5c42d06c61ef28c3578a700ce9e6d69d
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Fri Mar 7 14:57:42 2014 +0100
controller: try connection every second
Currently, with 10 tries, it takes up to n(n+1)/2 = 55s before
returning failure.
The default firefox plugin timeout is 45s, passed that time, the plugin
is killed. 10s should be enough in normal usage for the client to setup
the unix socket.
https://bugzilla.redhat.com/show_bug.cgi?id=1073461
diff --git a/SpiceXPI/src/plugin/controller.cpp b/SpiceXPI/src/plugin/controller.cpp
index e787012..988768b 100644
--- a/SpiceXPI/src/plugin/controller.cpp
+++ b/SpiceXPI/src/plugin/controller.cpp
@@ -88,14 +88,13 @@ void SpiceController::SetProxy(const std::string &proxy)
int SpiceController::Connect(const int nRetries)
{
int rc = -1;
- int sleep_time = 0;
+ int sleep_time = 1;
// try to connect for specified count
for (int i = 0; rc != 0 && i < nRetries; ++i)
{
rc = Connect();
g_usleep(sleep_time * G_USEC_PER_SEC);
- ++sleep_time;
}
if (rc != 0) {
g_warning("error connecting");
More information about the Spice-commits
mailing list