telepathy-idle: server-connection: fix race when writing to stream when closed

Jonny Lamb jonny at kemper.freedesktop.org
Mon May 14 13:14:40 PDT 2012


Module: telepathy-idle
Branch: master
Commit: 7f1093771689ffbef577bb245152eb25264ca32e
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=7f1093771689ffbef577bb245152eb25264ca32e

Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date:   Mon May 14 21:14:15 2012 +0100

server-connection: fix race when writing to stream when closed

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>

---

 src/idle-server-connection.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c
index 0975838..e131903 100644
--- a/src/idle-server-connection.c
+++ b/src/idle-server-connection.c
@@ -438,7 +438,8 @@ void idle_server_connection_send_async(IdleServerConnection *conn, const gchar *
 	GSimpleAsyncResult *result;
 	gsize output_buffer_size = sizeof(priv->output_buffer);
 
-	if (priv->state != SERVER_CONNECTION_STATE_CONNECTED) {
+	if (priv->state != SERVER_CONNECTION_STATE_CONNECTED
+            || priv->io_stream == NULL) {
 		IDLE_DEBUG("connection was not open!");
 		g_simple_async_report_error_in_idle(G_OBJECT(conn),
 			callback, user_data,
@@ -472,7 +473,9 @@ void idle_server_connection_send_async(IdleServerConnection *conn, const gchar *
 }
 
 gboolean idle_server_connection_send_finish(IdleServerConnection *conn, GAsyncResult *result, GError **error) {
-	g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(conn), idle_server_connection_send_async), FALSE);
+	/* we can't check the source tag here because we use
+	 * report_error_in_idle which never sets a source tag */
+	g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(conn), NULL), FALSE);
 	return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT(result), error);
 }
 



More information about the telepathy-commits mailing list