From 9a479e1933139df53741ce83fda3c7584c145081 Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Tue, 16 Sep 2008 23:29:22 +0000 Subject: Improve a few comments --- libpurple/dnsquery.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c index 0a9d5955b0..7bce52a39a 100644 --- a/libpurple/dnsquery.c +++ b/libpurple/dnsquery.c @@ -85,7 +85,7 @@ typedef struct { char hostname[512]; int port; } dns_params_t; -#endif +#endif /* end PURPLE_DNSQUERY_USE_FORK */ static void purple_dnsquery_resolved(PurpleDnsQueryData *query_data, GSList *hosts) @@ -419,9 +419,9 @@ purple_dnsquery_resolver_new(gboolean show_debug) /** * @return TRUE if the request was sent succesfully. FALSE - * if the request could not be sent. This isn't - * necessarily an error. If the child has expired, - * for example, we won't be able to send the message. + * if the request could not be sent. This isn't + * necessarily an error. If the child has expired, + * for example, we won't be able to send the message. */ static gboolean send_dns_request_to_child(PurpleDnsQueryData *query_data, @@ -912,10 +912,13 @@ purple_dnsquery_destroy(PurpleDnsQueryData *query_data) if (query_data->resolver != NULL) /* - * Ideally we would tell our resolver child to stop resolving - * shit and then we would add it back to the free_dns_children - * linked list. However, it's hard to tell children stuff, - * they just don't listen. + * This is only non-NULL when we're cancelling an in-progress + * query. Ideally we would tell our resolver child to stop + * resolving shit and then we would add it back to the + * free_dns_children linked list. However, it's hard to tell + * children stuff, they just don't listen. So we'll just + * kill the process and allow a new child to be started if we + * have more stuff to resolve. */ purple_dnsquery_resolver_destroy(query_data->resolver); #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ @@ -939,7 +942,7 @@ purple_dnsquery_destroy(PurpleDnsQueryData *query_data) query_data->hosts = g_slist_remove(query_data->hosts, query_data->hosts->data); } g_free(query_data->error_message); -#endif +#endif /* end _WIN32 */ if (query_data->timeout > 0) purple_timeout_remove(query_data->timeout); @@ -993,5 +996,5 @@ purple_dnsquery_uninit(void) purple_dnsquery_resolver_destroy(free_dns_children->data); free_dns_children = g_slist_remove(free_dns_children, free_dns_children->data); } -#endif +#endif /* end PURPLE_DNSQUERY_USE_FORK */ } -- cgit v1.2.1 From 3b47b320912db16a4e16e0187c78957c4503e192 Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Tue, 16 Sep 2008 23:30:47 +0000 Subject: Change a string to be more user friendly (people shouldn't have any idea what EOF means) --- libpurple/dnsquery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c index 7bce52a39a..491724da4e 100644 --- a/libpurple/dnsquery.c +++ b/libpurple/dnsquery.c @@ -596,7 +596,7 @@ host_resolved(gpointer data, gint source, PurpleInputCondition cond) purple_dnsquery_failed(query_data, message); } else if (rc == 0) { - g_snprintf(message, sizeof(message), _("EOF while reading from resolver process")); + g_snprintf(message, sizeof(message), _("Resolver process exited without answering our request")); purple_dnsquery_failed(query_data, message); } -- cgit v1.2.1 From 7a617909da4f990c71831c333286e969c9b3a12f Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Tue, 16 Sep 2008 23:32:15 +0000 Subject: Simplify two bits of code a little --- libpurple/dnsquery.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c index 491724da4e..425ba6af94 100644 --- a/libpurple/dnsquery.c +++ b/libpurple/dnsquery.c @@ -133,10 +133,7 @@ purple_dnsquery_ui_resolve(PurpleDnsQueryData *query_data) PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops(); if (ops && ops->resolve_host) - { - if (ops->resolve_host(query_data, purple_dnsquery_resolved, purple_dnsquery_failed)) - return TRUE; - } + return ops->resolve_host(query_data, purple_dnsquery_resolved, purple_dnsquery_failed); return FALSE; } @@ -634,7 +631,7 @@ purple_dnsquery_a(const char *hostname, int port, query_data->data = data; query_data->resolver = NULL; - if (strlen(query_data->hostname) == 0) + if (*query_data->hostname == '\0') { purple_dnsquery_destroy(query_data); g_return_val_if_reached(NULL); -- cgit v1.2.1 From 12bf1c683fa2fbc1e1cfa9809b93048d662bea9a Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Tue, 16 Sep 2008 23:35:45 +0000 Subject: There was a little weirdness with the code that called the UI function for resolving DNS queries. I don't think this affects anyone I know (not Pidgin, Finich, Adium or Meebo). It would affect someone running on Unix/Linux and using their own DNS resolution UI op. And even then the functionality should basically remain the same... The code is hopefully more clean this way in the event where ops->resolve_hosts is defined, but returns FALSE for some odd reason. --- libpurple/dnsquery.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c index 425ba6af94..7c8c59cafc 100644 --- a/libpurple/dnsquery.c +++ b/libpurple/dnsquery.c @@ -490,13 +490,6 @@ handle_next_queued_request(void) query_data = queued_requests->data; queued_requests = g_slist_delete_link(queued_requests, queued_requests); - if (purple_dnsquery_ui_resolve(query_data)) - { - /* The UI is handling the resolve; we're done */ - handle_next_queued_request(); - return; - } - /* * If we have any children, attempt to have them perform the DNS * query. If we're able to send the query then resolver will be @@ -608,6 +601,12 @@ resolve_host(gpointer data) query_data = data; query_data->timeout = 0; + if (purple_dnsquery_ui_resolve(query_data)) + { + /* The UI is handling the resolve; we're done */ + return FALSE; + } + handle_next_queued_request(); return FALSE; -- cgit v1.2.1 From 91f5d64e7c5881dcb8c71b4b00ce7a9dcd945729 Mon Sep 17 00:00:00 2001 From: Mark Doliner Date: Tue, 16 Sep 2008 23:37:36 +0000 Subject: Fix DNS resolution. I think I broke this this morning in my revision b2b1a42a78168eb8f19ba3398c0058b6a9cac4c5. I changed us to not free the child DNS resolvers, but also to not re-use them. So it would do 4 dns requests then just sit around waiting forever. Now resolvers are added to the list of idle resolvers after they're done resolving. --- libpurple/dnsquery.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c index 7c8c59cafc..c782a1e7aa 100644 --- a/libpurple/dnsquery.c +++ b/libpurple/dnsquery.c @@ -108,12 +108,14 @@ purple_dnsquery_resolved(PurpleDnsQueryData *query_data, GSList *hosts) } } +#ifdef PURPLE_DNSQUERY_USE_FORK /* - * Set the resolver to NULL so that it doesn't get killed so that - * it sits around waiting for additional DNS requests for a few - * seconds longer. + * Add the resolver to the list of available resolvers, and set it + * to NULL so that it doesn't get destroyed along with the query_data */ + free_dns_children = g_slist_prepend(free_dns_children, query_data->resolver); query_data->resolver = NULL; +#endif /* PURPLE_DNSQUERY_USE_FORK */ purple_dnsquery_destroy(query_data); } -- cgit v1.2.1