comparison libpurple/dnsquery.c @ 24080:005649461c77

In our child DNS lookup processes, don't bother to use select to watch the pipe with our parent. These processes don't do anything else, and they only need to watch one fd, so we can just use a blocking read() call. I don't think this will negatively affect anything, and it seems to fix some kind of funky rare race condition where the libpurple client will block while trying to read() a response from the child. If you think we should continue using select here, or you notice some problems with this, please let me know (and maybe even revert this)
author Mark Doliner <mark@kingant.net>
date Wed, 10 Sep 2008 21:48:33 +0000
parents f085e284f2df
children b703102fa0a5
comparison
equal deleted inserted replaced
24079:f085e284f2df 24080:005649461c77
207 * number from the socket with our parent. The bottom 207 * number from the socket with our parent. The bottom
208 * half of this resolves the IP (blocking) and sends 208 * half of this resolves the IP (blocking) and sends
209 * the result back to our parent, when finished. 209 * the result back to our parent, when finished.
210 */ 210 */
211 while (1) { 211 while (1) {
212 fd_set fds;
213 struct timeval tv = { .tv_sec = 40 , .tv_usec = 0 };
214 FD_ZERO(&fds);
215 FD_SET(child_in, &fds);
216 rc = select(child_in + 1, &fds, NULL, NULL, &tv);
217 if (!rc) {
218 if (show_debug)
219 printf("dns[%d]: nobody needs me... =(\n", getpid());
220 break;
221 }
222 rc = read(child_in, &dns_params, sizeof(dns_params_t)); 212 rc = read(child_in, &dns_params, sizeof(dns_params_t));
223 if (rc < 0) { 213 if (rc < 0) {
224 fprintf(stderr, "dns[%d]: Error: Could not read dns_params: " 214 fprintf(stderr, "dns[%d]: Error: Could not read dns_params: "
225 "%s\n", getpid(), strerror(errno)); 215 "%s\n", getpid(), strerror(errno));
226 break; 216 break;