temporarily reference connection while calling disconnect callback, so that it's safe for the callback to unref the connection
authorDafydd Harries <daf@rhydd.org>
Fri, 19 Oct 2007 16:57:31 +0100
changeset 284 5f82151c42ea
parent 282 0bd1892a18d3
child 285 7dee90bf5ee8
temporarily reference connection while calling disconnect callback, so that it's safe for the callback to unref the connection
loudmouth/lm-connection.c
--- a/loudmouth/lm-connection.c	Tue Oct 02 14:11:04 2007 +0200
+++ b/loudmouth/lm-connection.c	Fri Oct 19 16:57:31 2007 +0100
@@ -736,9 +736,11 @@
 	if (connection->disconnect_cb && connection->disconnect_cb->func) {
 		LmCallback *cb = connection->disconnect_cb;
 		
+		lm_connection_ref (connection);
 		(* ((LmDisconnectFunction) cb->func)) (connection,
 						       reason,
 						       cb->user_data);
+		lm_connection_unref (connection);
 	}
 }