Mercurial > pidgin.yaz
annotate libpurple/dnsquery.c @ 32808:2fdc668362f0
Use the purple_group_get_name() accessor function.
author | andrew.victor@mxit.com |
---|---|
date | Mon, 31 Oct 2011 19:00:39 +0000 |
parents | f22bc8b5b9dc |
children |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file dnsquery.c DNS query API |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15823 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16642
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 */ |
31980
92f3d821653f
purple: Fix some compiler warnings related to new API and missing prototypes.
Paul Aurich <paul@darkrain42.org>
parents:
31930
diff
changeset
|
27 #define _PURPLE_DNSQUERY_C_ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "dnsquery.h" |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
32 #include "network.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 |
27016
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
37 #ifndef _WIN32 |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
38 #include <resolv.h> |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
39 #endif |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
40 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
41 #if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__) |
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
42 #define PURPLE_DNSQUERY_USE_FORK |
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
43 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 * DNS query API |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
15823 | 48 static PurpleDnsQueryUiOps *dns_query_ui_ops = NULL; |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
49 |
15823 | 50 typedef struct _PurpleDnsQueryResolverProcess PurpleDnsQueryResolverProcess; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
15823 | 52 struct _PurpleDnsQueryData { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 char *hostname; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 int port; |
15823 | 55 PurpleDnsQueryConnectFunction callback; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 gpointer data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 guint timeout; |
31930
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
58 PurpleAccount *account; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
60 #if defined(PURPLE_DNSQUERY_USE_FORK) |
15823 | 61 PurpleDnsQueryResolverProcess *resolver; |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
62 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 GThread *resolver; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 GSList *hosts; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 gchar *error_message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
69 #if defined(PURPLE_DNSQUERY_USE_FORK) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 #define MAX_DNS_CHILDREN 4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 * This structure keeps a reference to a child resolver process. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 */ |
15823 | 76 struct _PurpleDnsQueryResolverProcess { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 guint inpa; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 int fd_in, fd_out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 pid_t dns_pid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 static GSList *free_dns_children = NULL; |
27553
bbf5c43e269a
Fix a leak of the queued_requests from purple_dnsquery_a.
aman@tmm1.net
parents:
27313
diff
changeset
|
83 /* TODO: Make me a GQueue when we require >= glib 2.4 */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 static GSList *queued_requests = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 static int number_of_dns_children = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 * This is a convenience struct used to pass data to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 * the child resolver process. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 typedef struct { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 char hostname[512]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 int port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 } dns_params_t; |
24053 | 96 #endif /* end PURPLE_DNSQUERY_USE_FORK */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 static void |
15823 | 99 purple_dnsquery_resolved(PurpleDnsQueryData *query_data, GSList *hosts) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 { |
15823 | 101 purple_debug_info("dnsquery", "IP resolved for %s\n", query_data->hostname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 if (query_data->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 query_data->callback(hosts, query_data->data, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 * Callback is a required parameter, but it can get set to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 * NULL if we cancel a thread-based DNS lookup. So we need |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 * to free hosts. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 while (hosts != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 hosts = g_slist_remove(hosts, hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 g_free(hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 hosts = g_slist_remove(hosts, hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 |
24057
cd35c0f680b9
Fix DNS resolution. I think I broke this this morning in my revision
Mark Doliner <mark@kingant.net>
parents:
24056
diff
changeset
|
119 #ifdef PURPLE_DNSQUERY_USE_FORK |
24052
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
120 /* |
24057
cd35c0f680b9
Fix DNS resolution. I think I broke this this morning in my revision
Mark Doliner <mark@kingant.net>
parents:
24056
diff
changeset
|
121 * Add the resolver to the list of available resolvers, and set it |
cd35c0f680b9
Fix DNS resolution. I think I broke this this morning in my revision
Mark Doliner <mark@kingant.net>
parents:
24056
diff
changeset
|
122 * to NULL so that it doesn't get destroyed along with the query_data |
24052
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
123 */ |
27555
5345dfe48272
Don't assume a resolver generated the response.
aman@tmm1.net
parents:
27554
diff
changeset
|
124 if (query_data->resolver) |
5345dfe48272
Don't assume a resolver generated the response.
aman@tmm1.net
parents:
27554
diff
changeset
|
125 { |
5345dfe48272
Don't assume a resolver generated the response.
aman@tmm1.net
parents:
27554
diff
changeset
|
126 free_dns_children = g_slist_prepend(free_dns_children, query_data->resolver); |
5345dfe48272
Don't assume a resolver generated the response.
aman@tmm1.net
parents:
27554
diff
changeset
|
127 query_data->resolver = NULL; |
5345dfe48272
Don't assume a resolver generated the response.
aman@tmm1.net
parents:
27554
diff
changeset
|
128 } |
24057
cd35c0f680b9
Fix DNS resolution. I think I broke this this morning in my revision
Mark Doliner <mark@kingant.net>
parents:
24056
diff
changeset
|
129 #endif /* PURPLE_DNSQUERY_USE_FORK */ |
24052
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
130 |
15823 | 131 purple_dnsquery_destroy(query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 static void |
15823 | 135 purple_dnsquery_failed(PurpleDnsQueryData *query_data, const gchar *error_message) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27016
diff
changeset
|
137 purple_debug_error("dnsquery", "%s\n", error_message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 if (query_data->callback != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 query_data->callback(NULL, query_data->data, error_message); |
15823 | 140 purple_dnsquery_destroy(query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
143 static gboolean |
15823 | 144 purple_dnsquery_ui_resolve(PurpleDnsQueryData *query_data) |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
145 { |
15823 | 146 PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops(); |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
147 |
15712
7ac07c5fb1c2
No changes; fixed a bunch of whitespace problems made by a text editor with 'use tabs' disabled. Sorry for the noise.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15710
diff
changeset
|
148 if (ops && ops->resolve_host) |
24055
dab570436008
Simplify two bits of code a little
Mark Doliner <mark@kingant.net>
parents:
24054
diff
changeset
|
149 return ops->resolve_host(query_data, purple_dnsquery_resolved, purple_dnsquery_failed); |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
150 |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
151 return FALSE; |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
152 } |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
153 |
27554 | 154 static gboolean |
155 resolve_ip(PurpleDnsQueryData *query_data) | |
156 { | |
32204
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
157 #if defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST) |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
158 struct addrinfo hints, *res; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
159 char servname[20]; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
160 |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
161 g_snprintf(servname, sizeof(servname), "%d", query_data->port); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
162 memset(&hints, 0, sizeof(hints)); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
163 hints.ai_family = AF_UNSPEC; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
164 hints.ai_flags |= AI_NUMERICHOST; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
165 |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
166 if (0 == getaddrinfo(query_data->hostname, servname, &hints, &res)) |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
167 { |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
168 GSList *hosts = NULL; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
169 hosts = g_slist_append(hosts, GINT_TO_POINTER(res->ai_addrlen)); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
170 hosts = g_slist_append(hosts, g_memdup(res->ai_addr, res->ai_addrlen)); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
171 purple_dnsquery_resolved(query_data, hosts); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
172 |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
173 freeaddrinfo(res); |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
174 return TRUE; |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
175 } |
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
176 #else /* defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST) */ |
27554 | 177 struct sockaddr_in sin; |
178 if (inet_aton(query_data->hostname, &sin.sin_addr)) | |
179 { | |
180 /* | |
181 * The given "hostname" is actually an IP address, so we | |
182 * don't need to do anything. | |
183 */ | |
184 GSList *hosts = NULL; | |
185 sin.sin_family = AF_INET; | |
186 sin.sin_port = htons(query_data->port); | |
187 hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); | |
188 hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); | |
189 purple_dnsquery_resolved(query_data, hosts); | |
190 | |
191 return TRUE; | |
192 } | |
32204
8dbe2f531a89
dnsquery: Behold, automagic conversion of a string IP address into a sockaddr struct, IPv#-independent.
Paul Aurich <paul@darkrain42.org>
parents:
31980
diff
changeset
|
193 #endif |
27554 | 194 |
195 return FALSE; | |
196 } | |
197 | |
28847
1c6c53143afe
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents:
28668
diff
changeset
|
198 #ifdef USE_IDN |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
199 static gboolean |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
200 dns_str_is_ascii(const char *name) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
201 { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
202 guchar *c; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
203 for (c = (guchar *)name; c && *c; ++c) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
204 if (*c > 0x7f) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
205 return FALSE; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
206 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
207 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
208 return TRUE; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
209 } |
28847
1c6c53143afe
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents:
28668
diff
changeset
|
210 #endif |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
211 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
212 #if defined(PURPLE_DNSQUERY_USE_FORK) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 * Unix! |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 * Begin the DNS resolver child process functions. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 #ifdef HAVE_SIGNAL_H |
16642
c028fc690b5d
Mark two functions as "noreturn"
Mark Doliner <mark@kingant.net>
parents:
15829
diff
changeset
|
222 G_GNUC_NORETURN static void |
22011
76e0463db3aa
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents:
22007
diff
changeset
|
223 trap_gdb_bug(int sig) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 const char *message = |
15823 | 226 "Purple's DNS child got a SIGTRAP signal.\n" |
227 "This can be caused by trying to run purple inside gdb.\n" | |
228 "There is a known gdb bug which prevents this. Supposedly purple\n" | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 "should have detected you were using gdb and used an ugly hack,\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 "check cope_with_gdb_brokenness() in dnsquery.c.\n\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 "For more info about this bug, see http://sources.redhat.com/ml/gdb/2001-07/msg00349.html\n"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 fputs("\n* * *\n",stderr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 fputs(message,stderr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 fputs("* * *\n\n",stderr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 execlp("xmessage","xmessage","-center", message, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 _exit(1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
240 static void |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
241 write_to_parent(int fd, const void *buf, size_t count) |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
242 { |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
243 ssize_t written; |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
244 |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
245 written = write(fd, buf, count); |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
246 if (written != count) { |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
247 if (written < 0) |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
248 fprintf(stderr, "dns[%d]: Error writing data to " |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
249 "parent: %s\n", getpid(), strerror(errno)); |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
250 else |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
251 fprintf(stderr, "dns[%d]: Error: Tried to write %" |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
252 G_GSIZE_FORMAT " bytes to parent but instead " |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
253 "wrote %" G_GSIZE_FORMAT " bytes\n", |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
254 getpid(), count, written); |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
255 } |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
256 } |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
257 |
16642
c028fc690b5d
Mark two functions as "noreturn"
Mark Doliner <mark@kingant.net>
parents:
15829
diff
changeset
|
258 G_GNUC_NORETURN static void |
15823 | 259 purple_dnsquery_resolver_run(int child_out, int child_in, gboolean show_debug) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 dns_params_t dns_params; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 const size_t zero = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 int rc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 struct addrinfo hints, *res, *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 char servname[20]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 struct sockaddr_in sin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 const size_t addrlen = sizeof(sin); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 #endif |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
271 char *hostname; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 #ifdef HAVE_SIGNAL_H |
15823 | 274 purple_restore_default_signal_handlers(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 signal(SIGTRAP, trap_gdb_bug); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 * We resolve 1 host name for each iteration of this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 * while loop. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 * The top half of this reads in the hostname and port |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 * number from the socket with our parent. The bottom |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 * half of this resolves the IP (blocking) and sends |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 * the result back to our parent, when finished. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 while (1) { |
24052
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
288 fd_set fds; |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
289 struct timeval tv = { .tv_sec = 20, .tv_usec = 0 }; |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
290 FD_ZERO(&fds); |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
291 FD_SET(child_in, &fds); |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
292 rc = select(child_in + 1, &fds, NULL, NULL, &tv); |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
293 if (!rc) { |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
294 if (show_debug) |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
295 printf("dns[%d]: nobody needs me... =(\n", getpid()); |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
296 break; |
5395b18f9f08
Revert my revision 849d4f7265598a9f0340411c4c0c0401d488ec3b, which
Mark Doliner <mark@kingant.net>
parents:
24012
diff
changeset
|
297 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 rc = read(child_in, &dns_params, sizeof(dns_params_t)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 if (rc < 0) { |
32405
d3d41ba0c3b8
In our forked DNS resolver processes, don't bail out if we get a retryable
Mark Doliner <mark@kingant.net>
parents:
32204
diff
changeset
|
300 if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { |
d3d41ba0c3b8
In our forked DNS resolver processes, don't bail out if we get a retryable
Mark Doliner <mark@kingant.net>
parents:
32204
diff
changeset
|
301 /* Try again */ |
d3d41ba0c3b8
In our forked DNS resolver processes, don't bail out if we get a retryable
Mark Doliner <mark@kingant.net>
parents:
32204
diff
changeset
|
302 continue; |
d3d41ba0c3b8
In our forked DNS resolver processes, don't bail out if we get a retryable
Mark Doliner <mark@kingant.net>
parents:
32204
diff
changeset
|
303 } |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
304 fprintf(stderr, "dns[%d]: Error: Could not read dns_params: " |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
305 "%s\n", getpid(), strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 if (rc == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 if (show_debug) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 printf("dns[%d]: Oops, father has gone, wait for me, wait...!\n", getpid()); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 _exit(0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 if (dns_params.hostname[0] == '\0') { |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
314 fprintf(stderr, "dns[%d]: Error: Parent requested resolution " |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
315 "of an empty hostname (port = %d)!!!\n", getpid(), |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
316 dns_params.port); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 _exit(1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
320 #ifdef USE_IDN |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
321 if (!dns_str_is_ascii(dns_params.hostname)) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
322 rc = purple_network_convert_idn_to_ascii(dns_params.hostname, &hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
323 if (rc != 0) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
324 write_to_parent(child_out, &rc, sizeof(rc)); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
325 if (show_debug) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
326 fprintf(stderr, "dns[%d] Error: IDN conversion returned " |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
327 "%d\n", getpid(), rc); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
328 dns_params.hostname[0] = '\0'; |
28848
4370819b97ff
dns: I don't think this worked correctly before.
Paul Aurich <paul@darkrain42.org>
parents:
28847
diff
changeset
|
329 break; |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
330 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
331 } else /* intentional to execute the g_strdup */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
332 #endif |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
333 hostname = g_strdup(dns_params.hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
334 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 /* We have the hostname and port, now resolve the IP */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 g_snprintf(servname, sizeof(servname), "%d", dns_params.port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 memset(&hints, 0, sizeof(hints)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 /* This is only used to convert a service |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 * name to a port number. As we know we are |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 * passing a number already, we know this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 * value will not be really used by the C |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 * library. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 hints.ai_socktype = SOCK_STREAM; |
27005
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
348 #ifdef AI_ADDRCONFIG |
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
349 hints.ai_flags |= AI_ADDRCONFIG; |
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
350 #endif /* AI_ADDRCONFIG */ |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
351 rc = getaddrinfo(hostname, servname, &hints, &res); |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
352 write_to_parent(child_out, &rc, sizeof(rc)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 if (rc != 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 if (show_debug) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 printf("dns[%d] Error: getaddrinfo returned %d\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 getpid(), rc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 dns_params.hostname[0] = '\0'; |
28666
4c58aa4aacb0
Minor leak fixes. Probably not too important since they're in DNS resolver
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28660
diff
changeset
|
358 g_free(hostname); |
4c58aa4aacb0
Minor leak fixes. Probably not too important since they're in DNS resolver
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28660
diff
changeset
|
359 hostname = NULL; |
28848
4370819b97ff
dns: I don't think this worked correctly before.
Paul Aurich <paul@darkrain42.org>
parents:
28847
diff
changeset
|
360 break; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 tmp = res; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 while (res) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 size_t ai_addrlen = res->ai_addrlen; |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
365 write_to_parent(child_out, &ai_addrlen, sizeof(ai_addrlen)); |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
366 write_to_parent(child_out, res->ai_addr, res->ai_addrlen); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 res = res->ai_next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 freeaddrinfo(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 #else |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
371 struct hostent *hp; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
372 if (!(hp = gethostbyname(hostname))) { |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
373 write_to_parent(child_out, &h_errno, sizeof(int)); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
374 close(child_out); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
375 if (show_debug) |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
376 printf("DNS Error: %d\n", h_errno); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
377 _exit(0); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
378 } |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
379 memset(&sin, 0, sizeof(struct sockaddr_in)); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
380 memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
381 sin.sin_family = hp->h_addrtype; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 sin.sin_port = htons(dns_params.port); |
24885
1596d09393cf
Ludovico Cavedon noticed that on 64-bit platforms, when HAVE_GETADDRINFO isn't
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24414
diff
changeset
|
384 rc = 0; |
1596d09393cf
Ludovico Cavedon noticed that on 64-bit platforms, when HAVE_GETADDRINFO isn't
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24414
diff
changeset
|
385 write_to_parent(child_out, &rc, sizeof(rc)); |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
386 write_to_parent(child_out, &addrlen, sizeof(addrlen)); |
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
387 write_to_parent(child_out, &sin, addrlen); |
24885
1596d09393cf
Ludovico Cavedon noticed that on 64-bit platforms, when HAVE_GETADDRINFO isn't
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24414
diff
changeset
|
388 #endif |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
22011
diff
changeset
|
389 write_to_parent(child_out, &zero, sizeof(zero)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 dns_params.hostname[0] = '\0'; |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
391 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
392 g_free(hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
393 hostname = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 close(child_out); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 close(child_in); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 _exit(0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 * End the DNS resolver child process functions. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 * Begin the functions for dealing with the DNS child processes. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 static void |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21862
diff
changeset
|
409 cope_with_gdb_brokenness(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 #ifdef __linux__ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 static gboolean already_done = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 char s[256], e[512]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 int n; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 pid_t ppid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 if(already_done) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 already_done = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 ppid = getppid(); |
26967
8290e36a5a73
A patch from Scott Wolchok to replace snprintf() with g_snprintf() and
Richard Laager <rlaager@wiktel.com>
parents:
24885
diff
changeset
|
421 g_snprintf(s, sizeof(s), "/proc/%d/exe", ppid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 n = readlink(s, e, sizeof(e)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 if(n < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 e[MIN(n,sizeof(e)-1)] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 if(strstr(e,"gdb")) { |
15823 | 429 purple_debug_info("dns", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 "Debugger detected, performing useless query...\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 gethostbyname("x.x.x.x.x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 static void |
15823 | 437 purple_dnsquery_resolver_destroy(PurpleDnsQueryResolverProcess *resolver) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 g_return_if_fail(resolver != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
24414
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
441 /* Keep this before the kill() call below. */ |
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
442 if (resolver->inpa != 0) { |
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
443 purple_input_remove(resolver->inpa); |
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
444 resolver->inpa = 0; |
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
445 } |
002a58d4af7d
Fix a crash Jacky Lam noted on devel@pidgin.im:
Richard Laager <rlaager@wiktel.com>
parents:
24114
diff
changeset
|
446 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 * We might as well attempt to kill our child process. It really |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 * doesn't matter if this fails, because children will expire on |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 * their own after a few seconds. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 if (resolver->dns_pid > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 kill(resolver->dns_pid, SIGKILL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 close(resolver->fd_in); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 close(resolver->fd_out); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 g_free(resolver); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 number_of_dns_children--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 |
15823 | 463 static PurpleDnsQueryResolverProcess * |
464 purple_dnsquery_resolver_new(gboolean show_debug) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 { |
15823 | 466 PurpleDnsQueryResolverProcess *resolver; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 int child_out[2], child_in[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 /* Create pipes for communicating with the child process */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 if (pipe(child_out) || pipe(child_in)) { |
15823 | 471 purple_debug_error("dns", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
472 "Could not create pipes: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 |
15823 | 476 resolver = g_new(PurpleDnsQueryResolverProcess, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 resolver->inpa = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 cope_with_gdb_brokenness(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 /* "Go fork and multiply." --Tommy Caldwell (Emily's dad, not the climber) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 resolver->dns_pid = fork(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 /* If we are the child process... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 if (resolver->dns_pid == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 /* We should not access the parent's side of the pipes, so close them */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 close(child_out[0]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 close(child_in[1]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 |
15823 | 490 purple_dnsquery_resolver_run(child_out[1], child_in[0], show_debug); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 /* The thread calls _exit() rather than returning, so we never get here */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 /* We should not access the child's side of the pipes, so close them */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 close(child_out[1]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 close(child_in[0]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 if (resolver->dns_pid == -1) { |
15823 | 498 purple_debug_error("dns", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 "Could not create child process for DNS: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
500 g_strerror(errno)); |
15823 | 501 purple_dnsquery_resolver_destroy(resolver); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 resolver->fd_out = child_out[0]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 resolver->fd_in = child_in[1]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 number_of_dns_children++; |
15823 | 508 purple_debug_info("dns", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 "Created new DNS child %d, there are now %d children.\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 resolver->dns_pid, number_of_dns_children); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 return resolver; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 * @return TRUE if the request was sent succesfully. FALSE |
24053 | 517 * if the request could not be sent. This isn't |
518 * necessarily an error. If the child has expired, | |
519 * for example, we won't be able to send the message. | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 static gboolean |
15823 | 522 send_dns_request_to_child(PurpleDnsQueryData *query_data, |
523 PurpleDnsQueryResolverProcess *resolver) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 pid_t pid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 dns_params_t dns_params; |
24012
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
527 ssize_t rc; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 /* This waitpid might return the child's PID if it has recently |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 * exited, or it might return an error if it exited "long |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 * enough" ago that it has already been reaped; in either |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 * instance, we can't use it. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 pid = waitpid(resolver->dns_pid, NULL, WNOHANG); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 if (pid > 0) { |
15823 | 535 purple_debug_warning("dns", "DNS child %d no longer exists\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 resolver->dns_pid); |
15823 | 537 purple_dnsquery_resolver_destroy(resolver); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 } else if (pid < 0) { |
15823 | 540 purple_debug_warning("dns", "Wait for DNS child %d failed: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
541 resolver->dns_pid, g_strerror(errno)); |
15823 | 542 purple_dnsquery_resolver_destroy(resolver); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 /* Copy the hostname and port into a single data structure */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 strncpy(dns_params.hostname, query_data->hostname, sizeof(dns_params.hostname) - 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 dns_params.hostname[sizeof(dns_params.hostname) - 1] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 dns_params.port = query_data->port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 /* Send the data structure to the child */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 rc = write(resolver->fd_in, &dns_params, sizeof(dns_params)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 if (rc < 0) { |
22475
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22107
diff
changeset
|
554 purple_debug_error("dns", "Unable to write to DNS child %d: %s\n", |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
555 resolver->dns_pid, g_strerror(errno)); |
15823 | 556 purple_dnsquery_resolver_destroy(resolver); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 } |
24012
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
559 if (rc < sizeof(dns_params)) { |
24114
6c8f5ebbb6b7
Fix this debug message. Thanks to fledermaus who pointed it out.
Mark Doliner <mark@kingant.net>
parents:
24057
diff
changeset
|
560 purple_debug_error("dns", "Tried to write %" G_GSSIZE_FORMAT |
6c8f5ebbb6b7
Fix this debug message. Thanks to fledermaus who pointed it out.
Mark Doliner <mark@kingant.net>
parents:
24057
diff
changeset
|
561 " bytes to child but only wrote %" G_GSSIZE_FORMAT "\n", |
24012
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
562 sizeof(dns_params), rc); |
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
563 purple_dnsquery_resolver_destroy(resolver); |
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
564 return FALSE; |
b703102fa0a5
Fix this g_return_val_if_fail. It should have been returning TRUE or
Mark Doliner <mark@kingant.net>
parents:
24011
diff
changeset
|
565 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 |
15823 | 567 purple_debug_info("dns", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 "Successfully sent DNS request to child %d\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 resolver->dns_pid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 query_data->resolver = resolver; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 |
15823 | 576 static void host_resolved(gpointer data, gint source, PurpleInputCondition cond); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 static void |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21862
diff
changeset
|
579 handle_next_queued_request(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 { |
15823 | 581 PurpleDnsQueryData *query_data; |
582 PurpleDnsQueryResolverProcess *resolver; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 if (queued_requests == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 /* No more DNS queries, yay! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 query_data = queued_requests->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 queued_requests = g_slist_delete_link(queued_requests, queued_requests); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 * If we have any children, attempt to have them perform the DNS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 * query. If we're able to send the query then resolver will be |
15823 | 594 * set to the PurpleDnsQueryResolverProcess. Otherwise, resolver |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 * will be NULL and we'll need to create a new DNS request child. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 while (free_dns_children != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 resolver = free_dns_children->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 free_dns_children = g_slist_remove(free_dns_children, resolver); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 if (send_dns_request_to_child(query_data, resolver)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 /* We found an acceptable child, yay */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 /* We need to create a new DNS request child */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 if (query_data->resolver == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 if (number_of_dns_children >= MAX_DNS_CHILDREN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 /* Apparently all our children are busy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 queued_requests = g_slist_prepend(queued_requests, query_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 |
15823 | 617 resolver = purple_dnsquery_resolver_new(purple_debug_is_enabled()); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 if (resolver == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 { |
15823 | 620 purple_dnsquery_failed(query_data, _("Unable to create new resolver process\n")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 if (!send_dns_request_to_child(query_data, resolver)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 { |
15823 | 625 purple_dnsquery_failed(query_data, _("Unable to send request to resolver process\n")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 |
15823 | 630 query_data->resolver->inpa = purple_input_add(query_data->resolver->fd_out, |
631 PURPLE_INPUT_READ, host_resolved, query_data); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 * End the functions for dealing with the DNS child processes. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 static void |
15823 | 639 host_resolved(gpointer data, gint source, PurpleInputCondition cond) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 { |
15823 | 641 PurpleDnsQueryData *query_data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 int rc, err; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 GSList *hosts = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 struct sockaddr *addr = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 size_t addrlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 char message[1024]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 query_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 |
15823 | 650 purple_debug_info("dns", "Got response for '%s'\n", query_data->hostname); |
651 purple_input_remove(query_data->resolver->inpa); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 query_data->resolver->inpa = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 rc = read(query_data->resolver->fd_out, &err, sizeof(err)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 if ((rc == 4) && (err != 0)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 g_snprintf(message, sizeof(message), _("Error resolving %s:\n%s"), |
21862
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21121
diff
changeset
|
659 query_data->hostname, purple_gai_strerror(err)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 query_data->hostname, err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 #endif |
27016
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
664 /* Re-read resolv.conf and friends in case DNS servers have changed */ |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
665 res_init(); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
27005
diff
changeset
|
666 |
15823 | 667 purple_dnsquery_failed(query_data, message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 } else if (rc > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 /* Success! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 while (rc > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 rc = read(query_data->resolver->fd_out, &addrlen, sizeof(addrlen)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 if (rc > 0 && addrlen > 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 addr = g_malloc(addrlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 rc = read(query_data->resolver->fd_out, addr, addrlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 hosts = g_slist_append(hosts, GINT_TO_POINTER(addrlen)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 hosts = g_slist_append(hosts, addr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 /* wait4(resolver->dns_pid, NULL, WNOHANG, NULL); */ |
15823 | 682 purple_dnsquery_resolved(query_data, hosts); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 } else if (rc == -1) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
685 g_snprintf(message, sizeof(message), _("Error reading from resolver process:\n%s"), g_strerror(errno)); |
15823 | 686 purple_dnsquery_failed(query_data, message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 } else if (rc == 0) { |
24054
14c5a8bbaa8d
Change a string to be more user friendly (people shouldn't have any idea
Mark Doliner <mark@kingant.net>
parents:
24053
diff
changeset
|
689 g_snprintf(message, sizeof(message), _("Resolver process exited without answering our request")); |
15823 | 690 purple_dnsquery_failed(query_data, message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 handle_next_queued_request(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
696 static void |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
697 resolve_host(PurpleDnsQueryData *query_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 { |
27553
bbf5c43e269a
Fix a leak of the queued_requests from purple_dnsquery_a.
aman@tmm1.net
parents:
27313
diff
changeset
|
699 queued_requests = g_slist_append(queued_requests, query_data); |
bbf5c43e269a
Fix a leak of the queued_requests from purple_dnsquery_a.
aman@tmm1.net
parents:
27313
diff
changeset
|
700 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 handle_next_queued_request(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
704 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 * Windows! |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 dns_main_thread_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 { |
20320
6a128c9bd170
applied changes from 77376fe079e753b612b3b8c901060e689f3dee11
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
713 PurpleDnsQueryData *query_data = data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 |
20320
6a128c9bd170
applied changes from 77376fe079e753b612b3b8c901060e689f3dee11
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
715 /* We're done, so purple_dnsquery_destroy() shouldn't think it is canceling an in-progress lookup */ |
6a128c9bd170
applied changes from 77376fe079e753b612b3b8c901060e689f3dee11
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
716 query_data->resolver = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 if (query_data->error_message != NULL) |
15823 | 719 purple_dnsquery_failed(query_data, query_data->error_message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 GSList *hosts; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 |
15823 | 724 /* We don't want purple_dns_query_resolved() to free(hosts) */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 hosts = query_data->hosts; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 query_data->hosts = NULL; |
15823 | 727 purple_dnsquery_resolved(query_data, hosts); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 static gpointer |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 dns_thread(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 { |
15823 | 736 PurpleDnsQueryData *query_data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 int rc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 struct addrinfo hints, *res, *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 char servname[20]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 struct sockaddr_in sin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 struct hostent *hp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 #endif |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
745 char *hostname; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 query_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
749 #ifdef USE_IDN |
27714
8b669aaa3ed7
Build fix on Windows. Thanks to SuperMMX.
Paul Aurich <paul@darkrain42.org>
parents:
27711
diff
changeset
|
750 if (!dns_str_is_ascii(query_data->hostname)) { |
8b669aaa3ed7
Build fix on Windows. Thanks to SuperMMX.
Paul Aurich <paul@darkrain42.org>
parents:
27711
diff
changeset
|
751 rc = purple_network_convert_idn_to_ascii(query_data->hostname, &hostname); |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
752 if (rc != 0) { |
28667
160b864e3d9b
Fix a string now that we're not in string freeze. Thanks, QuLogic!
Paul Aurich <paul@darkrain42.org>
parents:
28660
diff
changeset
|
753 query_data->error_message = g_strdup_printf(_("Error converting %s " |
160b864e3d9b
Fix a string now that we're not in string freeze. Thanks, QuLogic!
Paul Aurich <paul@darkrain42.org>
parents:
28660
diff
changeset
|
754 "to punycode: %d"), query_data->hostname, rc); |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
755 /* back to main thread */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
756 purple_timeout_add(0, dns_main_thread_cb, query_data); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
757 return 0; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
758 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
759 } else /* intentional fallthru */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
760 #endif |
27714
8b669aaa3ed7
Build fix on Windows. Thanks to SuperMMX.
Paul Aurich <paul@darkrain42.org>
parents:
27711
diff
changeset
|
761 hostname = g_strdup(query_data->hostname); |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
762 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 g_snprintf(servname, sizeof(servname), "%d", query_data->port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 memset(&hints,0,sizeof(hints)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 * This is only used to convert a service |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 * name to a port number. As we know we are |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 * passing a number already, we know this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 * value will not be really used by the C |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 * library. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 hints.ai_socktype = SOCK_STREAM; |
27005
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
775 #ifdef AI_ADDRCONFIG |
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
776 hints.ai_flags |= AI_ADDRCONFIG; |
cf373257effb
Don't do IPv6 AAAA lookups if there is no IPv6 address configured on
Mark Doliner <mark@kingant.net>
parents:
26967
diff
changeset
|
777 #endif /* AI_ADDRCONFIG */ |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
778 if ((rc = getaddrinfo(hostname, servname, &hints, &res)) == 0) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 tmp = res; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 while(res) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 query_data->hosts = g_slist_append(query_data->hosts, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 GSIZE_TO_POINTER(res->ai_addrlen)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 query_data->hosts = g_slist_append(query_data->hosts, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 g_memdup(res->ai_addr, res->ai_addrlen)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 res = res->ai_next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 freeaddrinfo(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 } else { |
21862
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21121
diff
changeset
|
789 query_data->error_message = g_strdup_printf(_("Error resolving %s:\n%s"), query_data->hostname, purple_gai_strerror(rc)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 #else |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
792 if ((hp = gethostbyname(hostname))) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 memset(&sin, 0, sizeof(struct sockaddr_in)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
794 memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 sin.sin_family = hp->h_addrtype; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 sin.sin_port = htons(query_data->port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 query_data->hosts = g_slist_append(query_data->hosts, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 GSIZE_TO_POINTER(sizeof(sin))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 query_data->hosts = g_slist_append(query_data->hosts, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 g_memdup(&sin, sizeof(sin))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 query_data->error_message = g_strdup_printf(_("Error resolving %s: %d"), query_data->hostname, h_errno); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 #endif |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
806 g_free(hostname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 /* back to main thread */ |
20320
6a128c9bd170
applied changes from 77376fe079e753b612b3b8c901060e689f3dee11
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
809 purple_timeout_add(0, dns_main_thread_cb, query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
814 static void |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
815 resolve_host(PurpleDnsQueryData *query_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 GError *err = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
819 /* |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
820 * Spin off a separate thread to perform the DNS lookup so |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
821 * that we don't block the UI. |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
822 */ |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
823 query_data->resolver = g_thread_create(dns_thread, |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
824 query_data, FALSE, &err); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
825 if (query_data->resolver == NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 { |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
827 char message[1024]; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
828 g_snprintf(message, sizeof(message), _("Thread creation failure: %s"), |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
829 (err && err->message) ? err->message : _("Unknown reason")); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
830 g_error_free(err); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
831 purple_dnsquery_failed(query_data, message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
835 #else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 * We weren't able to do anything fancier above, so use the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 * fail-safe name resolution code, which is blocking. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
842 static void |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
843 resolve_host(PurpleDnsQueryData *query_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 struct sockaddr_in sin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 GSList *hosts = NULL; |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
847 struct hostent *hp; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
848 gchar *hostname; |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27555
diff
changeset
|
849 #ifdef USE_IDN |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
850 if (!dns_str_is_ascii(query_data->hostname)) { |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
851 int ret = purple_network_convert_idn_to_ascii(query_data->hostname, |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
852 &hostname); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
853 if (ret != 0) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 char message[1024]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
856 query_data->hostname, ret); |
15823 | 857 purple_dnsquery_failed(query_data, message); |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
858 return; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 } |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
860 } else /* fallthrough is intentional to the g_strdup */ |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
861 #endif |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
862 hostname = g_strdup(query_data->hostname); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
863 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
864 if(!(hp = gethostbyname(hostname))) { |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
865 char message[1024]; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
866 g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
867 query_data->hostname, h_errno); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
868 purple_dnsquery_failed(query_data, message); |
28660
578b4048a501
More tightly scope a variable and avoid trying to free an unset variable.
brian.lu@sun.com
parents:
27714
diff
changeset
|
869 g_free(hostname); |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
870 return; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
871 } |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
872 memset(&sin, 0, sizeof(struct sockaddr_in)); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
873 memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length); |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
874 sin.sin_family = hp->h_addrtype; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
875 g_free(hostname); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
876 sin.sin_port = htons(query_data->port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 |
15823 | 881 purple_dnsquery_resolved(query_data, hosts); |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
882 } |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
883 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
884 #endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */ |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
885 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
886 static gboolean |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
887 initiate_resolving(gpointer data) |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
888 { |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
889 PurpleDnsQueryData *query_data; |
31930
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
890 PurpleProxyType proxy_type; |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
891 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
892 query_data = data; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
893 query_data->timeout = 0; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
894 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
895 if (resolve_ip(query_data)) |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
896 /* resolve_ip calls purple_dnsquery_resolved */ |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
897 return FALSE; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
898 |
31930
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
899 proxy_type = purple_proxy_info_get_type( |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
900 purple_proxy_get_setup(query_data->account)); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
901 if (proxy_type == PURPLE_PROXY_TOR) { |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
902 purple_dnsquery_failed(query_data, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
903 _("Aborting DNS lookup in Tor Proxy mode.")); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
904 return FALSE; |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
905 } |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
906 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
907 if (purple_dnsquery_ui_resolve(query_data)) |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
908 /* The UI is handling the resolve; we're done */ |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
909 return FALSE; |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
910 |
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
911 resolve_host(query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 |
15823 | 916 PurpleDnsQueryData * |
32474
f22bc8b5b9dc
Replace purple_dnsquery_a_account with purple_dnsquery_a.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32405
diff
changeset
|
917 purple_dnsquery_a(PurpleAccount *account, const char *hostname, int port, |
15823 | 918 PurpleDnsQueryConnectFunction callback, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 { |
15823 | 920 PurpleDnsQueryData *query_data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 g_return_val_if_fail(hostname != NULL, NULL); |
31925
74e2492967be
Consolidate duplicated implementations of purple_dnsquery_a
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28848
diff
changeset
|
923 g_return_val_if_fail(port != 0, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 g_return_val_if_fail(callback != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 |
31925
74e2492967be
Consolidate duplicated implementations of purple_dnsquery_a
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28848
diff
changeset
|
926 purple_debug_info("dnsquery", "Performing DNS lookup for %s\n", hostname); |
74e2492967be
Consolidate duplicated implementations of purple_dnsquery_a
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28848
diff
changeset
|
927 |
74e2492967be
Consolidate duplicated implementations of purple_dnsquery_a
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28848
diff
changeset
|
928 query_data = g_new0(PurpleDnsQueryData, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 query_data->hostname = g_strdup(hostname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 g_strstrip(query_data->hostname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 query_data->port = port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 query_data->callback = callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 query_data->data = data; |
31930
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31926
diff
changeset
|
934 query_data->account = account; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
935 |
31925
74e2492967be
Consolidate duplicated implementations of purple_dnsquery_a
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28848
diff
changeset
|
936 if (*query_data->hostname == '\0') |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 { |
15823 | 938 purple_dnsquery_destroy(query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 g_return_val_if_reached(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 |
31926
68a1efda3654
Further consolidation of dnsquery code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31925
diff
changeset
|
942 query_data->timeout = purple_timeout_add(0, initiate_resolving, query_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 return query_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 void |
15823 | 948 purple_dnsquery_destroy(PurpleDnsQueryData *query_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 { |
15823 | 950 PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops(); |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
951 |
15712
7ac07c5fb1c2
No changes; fixed a bunch of whitespace problems made by a text editor with 'use tabs' disabled. Sorry for the noise.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15710
diff
changeset
|
952 if (ops && ops->destroy) |
7ac07c5fb1c2
No changes; fixed a bunch of whitespace problems made by a text editor with 'use tabs' disabled. Sorry for the noise.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15710
diff
changeset
|
953 ops->destroy(query_data); |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
954 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
955 #if defined(PURPLE_DNSQUERY_USE_FORK) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 queued_requests = g_slist_remove(queued_requests, query_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 if (query_data->resolver != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 /* |
24053 | 960 * This is only non-NULL when we're cancelling an in-progress |
961 * query. Ideally we would tell our resolver child to stop | |
962 * resolving shit and then we would add it back to the | |
963 * free_dns_children linked list. However, it's hard to tell | |
964 * children stuff, they just don't listen. So we'll just | |
965 * kill the process and allow a new child to be started if we | |
966 * have more stuff to resolve. | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 */ |
15823 | 968 purple_dnsquery_resolver_destroy(query_data->resolver); |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
969 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 if (query_data->resolver != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 * It's not really possible to kill a thread. So instead we |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 * just set the callback to NULL and let the DNS lookup |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 * finish. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 query_data->callback = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 while (query_data->hosts != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 /* Discard the length... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 query_data->hosts = g_slist_remove(query_data->hosts, query_data->hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 /* Free the address... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 g_free(query_data->hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 query_data->hosts = g_slist_remove(query_data->hosts, query_data->hosts->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 g_free(query_data->error_message); |
24053 | 990 #endif /* end _WIN32 */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 if (query_data->timeout > 0) |
15823 | 993 purple_timeout_remove(query_data->timeout); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 g_free(query_data->hostname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 g_free(query_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
999 char * |
15823 | 1000 purple_dnsquery_get_host(PurpleDnsQueryData *query_data) |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1001 { |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1002 g_return_val_if_fail(query_data != NULL, NULL); |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1003 |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1004 return query_data->hostname; |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1005 } |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1006 |
15710
d253c87a6a1f
Remove a g_return_val_if_fail() which isn't needed, made gaim_dnsquery_get_port() return an unsigned short and return 0 if query_data is NULL, and fixed a whitespace mistake
Evan Schoenberg <evan.s@dreskin.net>
parents:
15706
diff
changeset
|
1007 unsigned short |
15823 | 1008 purple_dnsquery_get_port(PurpleDnsQueryData *query_data) |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1009 { |
15710
d253c87a6a1f
Remove a g_return_val_if_fail() which isn't needed, made gaim_dnsquery_get_port() return an unsigned short and return 0 if query_data is NULL, and fixed a whitespace mistake
Evan Schoenberg <evan.s@dreskin.net>
parents:
15706
diff
changeset
|
1010 g_return_val_if_fail(query_data != NULL, 0); |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1011 |
15712
7ac07c5fb1c2
No changes; fixed a bunch of whitespace problems made by a text editor with 'use tabs' disabled. Sorry for the noise.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15710
diff
changeset
|
1012 return query_data->port; |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1013 } |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1014 |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1015 void |
15823 | 1016 purple_dnsquery_set_ui_ops(PurpleDnsQueryUiOps *ops) |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1017 { |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1018 dns_query_ui_ops = ops; |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1019 } |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1020 |
15823 | 1021 PurpleDnsQueryUiOps * |
1022 purple_dnsquery_get_ui_ops(void) | |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1023 { |
15710
d253c87a6a1f
Remove a g_return_val_if_fail() which isn't needed, made gaim_dnsquery_get_port() return an unsigned short and return 0 if query_data is NULL, and fixed a whitespace mistake
Evan Schoenberg <evan.s@dreskin.net>
parents:
15706
diff
changeset
|
1024 /* It is perfectly acceptable for dns_query_ui_ops to be NULL; this just |
d253c87a6a1f
Remove a g_return_val_if_fail() which isn't needed, made gaim_dnsquery_get_port() return an unsigned short and return 0 if query_data is NULL, and fixed a whitespace mistake
Evan Schoenberg <evan.s@dreskin.net>
parents:
15706
diff
changeset
|
1025 * means that the default platform-specific implementation will be used. |
d253c87a6a1f
Remove a g_return_val_if_fail() which isn't needed, made gaim_dnsquery_get_port() return an unsigned short and return 0 if query_data is NULL, and fixed a whitespace mistake
Evan Schoenberg <evan.s@dreskin.net>
parents:
15706
diff
changeset
|
1026 */ |
15705
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1027 return dns_query_ui_ops; |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1028 } |
6a0b9734a722
The UI can now use the GaimDnsQueryUiOps to handle DNS resolving itself; if this is done, the platform-specific DNS query code won't be used. This will be used in Adium to use an efficient threads-based DNS resolve (since Adium is already multithreaded, this is significantly cheaper than fork()).
Evan Schoenberg <evan.s@dreskin.net>
parents:
15646
diff
changeset
|
1029 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 void |
15823 | 1031 purple_dnsquery_init(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1034 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1035 void |
15823 | 1036 purple_dnsquery_uninit(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 { |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22475
diff
changeset
|
1038 #if defined(PURPLE_DNSQUERY_USE_FORK) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1039 while (free_dns_children != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1040 { |
15823 | 1041 purple_dnsquery_resolver_destroy(free_dns_children->data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 free_dns_children = g_slist_remove(free_dns_children, free_dns_children->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 } |
24053 | 1044 #endif /* end PURPLE_DNSQUERY_USE_FORK */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 } |