# HG changeset patch # User Daniel Atallah # Date 1181100126 0 # Node ID a62a695ccfb5d8150937771152204af57830c420 # Parent eae7a411e3a1487ef71c1a05cb9af3339c9a6508 Improve Bonjour error handling when there are errors "connecting". diff -r eae7a411e3a1 -r a62a695ccfb5 libpurple/protocols/bonjour/bonjour.c --- a/libpurple/protocols/bonjour/bonjour.c Wed Jun 06 03:21:04 2007 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Wed Jun 06 03:22:06 2007 +0000 @@ -94,14 +94,13 @@ bonjour_login(PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); - PurpleGroup *bonjour_group = NULL; - BonjourData *bd = NULL; + PurpleGroup *bonjour_group; + BonjourData *bd; PurpleStatus *status; PurplePresence *presence; gc->flags |= PURPLE_CONNECTION_HTML; - gc->proto_data = g_new0(BonjourData, 1); - bd = gc->proto_data; + gc->proto_data = bd = g_new0(BonjourData, 1); /* Start waiting for jabber connections (iChat style) */ bd->jabber_data = g_new(BonjourJabber, 1); @@ -111,10 +110,6 @@ if (bonjour_jabber_start(bd->jabber_data) == -1) { /* Send a message about the connection error */ purple_connection_error(gc, _("Unable to listen for incoming IM connections\n")); - - /* Free the data */ - g_free(bd->jabber_data); - bd->jabber_data = NULL; return; } @@ -155,7 +150,7 @@ bonjour_close(PurpleConnection *connection) { PurpleGroup *bonjour_group; - BonjourData *bd = (BonjourData*)connection->proto_data; + BonjourData *bd = connection->proto_data; /* Stop looking for buddies in the LAN */ if (bd->dns_sd_data != NULL) diff -r eae7a411e3a1 -r a62a695ccfb5 libpurple/protocols/bonjour/jabber.c --- a/libpurple/protocols/bonjour/jabber.c Wed Jun 06 03:21:04 2007 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Wed Jun 06 03:22:06 2007 +0000 @@ -668,8 +668,10 @@ GSList *l; /* Close the server socket and remove all the watcher */ - close(data->socket); - purple_input_remove(data->watcher_id); + if (data->socket >= 0) + close(data->socket); + if (data->watcher_id > 0) + purple_input_remove(data->watcher_id); /* Close all the sockets and remove all the watchers after sending end streams */ if (data->account->gc != NULL)