2006-06-25 Mikael Hallendal <micke@imendio.com>
authorhallski <hallski>
Sun, 25 Jun 2006 10:28:28 +0000
changeset 157 46f819771198
parent 152 c736903f577b
child 158 1bf5aba521dd
2006-06-25 Mikael Hallendal <micke@imendio.com> * loudmouth/lm-connection.c: (lm_connection_close): - Patch from Martyn Russel - Make sure that disconnect is signalled if the connection is closed during opening phase. - Fixes LM-43
ChangeLog
loudmouth/lm-connection.c
--- a/ChangeLog	Tue Jun 06 12:39:19 2006 +0000
+++ b/ChangeLog	Sun Jun 25 10:28:28 2006 +0000
@@ -1,3 +1,11 @@
+2006-06-25  Mikael Hallendal  <micke@imendio.com>
+
+	* loudmouth/lm-connection.c: (lm_connection_close):
+	- Patch from Martyn Russel
+	- Make sure that disconnect is signalled if the connection is closed
+	  during opening phase.
+	- Fixes LM-43
+
 2006-06-06  Mikael Hallendal  <micke@imendio.com>
 
 	* loudmouth/lm-connection.c: (connection_free):
--- a/loudmouth/lm-connection.c	Tue Jun 06 12:39:19 2006 +0000
+++ b/loudmouth/lm-connection.c	Sun Jun 25 10:28:28 2006 +0000
@@ -1490,9 +1490,11 @@
 lm_connection_close (LmConnection      *connection, 
 		     GError           **error)
 {
+	gboolean no_errors = TRUE;
+
 	g_return_val_if_fail (connection != NULL, FALSE);
-	
-	if (!lm_connection_is_open (connection)) {
+
+	if (connection->state == LM_CONNECTION_STATE_CLOSED) {
 		g_set_error (error,
 			     LM_ERROR,
 			     LM_ERROR_CONNECTION_NOT_OPEN,
@@ -1503,16 +1505,18 @@
 	lm_verbose ("Disconnecting from: %s:%d\n", 
 		    connection->server, connection->port);
 	
-	if (!connection_send (connection, "</stream:stream>", -1, error)) {
-		return FALSE;
+	if (lm_connection_is_open (connection)) {
+		if (!connection_send (connection, "</stream:stream>", -1, error)) {
+			no_errors = FALSE;
+		}
+		
+		g_io_channel_flush (connection->io_channel, NULL);
 	}
 	
- 	g_io_channel_flush (connection->io_channel, NULL);
-	
 	connection_do_close (connection);
 	connection_signal_disconnect (connection, LM_DISCONNECT_REASON_OK);
 	
-	return TRUE;
+	return no_errors;
 }
 
 /**