[Spice-devel] [PATCH spice-gtk] Allow open_fd() to be called with -1

Marc-André Lureau marcandre.lureau at gmail.com
Wed Feb 29 05:03:03 PST 2012


In this case, a valid fd will be requested via the
SpiceChannel::open-fd signal.
---
 gtk/spice-channel.c |    8 ++++++--
 gtk/spice-session.c |    8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 972a3bb..c1c145a 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2302,10 +2302,14 @@ gboolean spice_channel_connect(SpiceChannel *channel)
 /**
  * spice_channel_open_fd:
  * @channel:
- * @fd: a file descriptor (socket)
+ * @fd: a file descriptor (socket) or -1.
+ * request mechanism
  *
  * Connect the channel using @fd socket.
  *
+ * If @fd is -1, a valid fd will be requested later via the
+ * SpiceChannel::open-fd signal.
+ *
  * Returns: %TRUE on success.
  **/
 gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
@@ -2313,7 +2317,7 @@ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
     SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
 
     g_return_val_if_fail(c != NULL, FALSE);
-    g_return_val_if_fail(fd >= 0, FALSE);
+    g_return_val_if_fail(fd >= -1, FALSE);
 
     c->fd = fd;
 
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index c328f66..dca9b3a 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1042,12 +1042,15 @@ gboolean spice_session_connect(SpiceSession *session)
 /**
  * spice_session_open_fd:
  * @session:
- * @fd: a file descriptor
+ * @fd: a file descriptor (socket) or -1
  *
  * Open the session using the provided @fd socket file
  * descriptor. This is useful if you create the fd yourself, for
  * example to setup a SSH tunnel.
  *
+ * If @fd is -1, a valid fd will be requested later via the
+ * SpiceChannel::open-fd signal.
+ *
  * Returns:
  **/
 gboolean spice_session_open_fd(SpiceSession *session, int fd)
@@ -1055,9 +1058,10 @@ gboolean spice_session_open_fd(SpiceSession *session, int fd)
     SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
 
     g_return_val_if_fail(s != NULL, FALSE);
-    g_return_val_if_fail(fd >= 0, FALSE);
+    g_return_val_if_fail(fd >= -1, FALSE);
 
     spice_session_disconnect(session);
+    s->disconnecting = FALSE;
 
     s->client_provided_sockets = TRUE;
 
-- 
1.7.7.6



More information about the Spice-devel mailing list