summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoritojun <>2002-07-24 01:38:34 +0000
committeritojun <>2002-07-24 01:38:34 +0000
commitb6d268488e8a9312eb674665715a44b1a6c599cf (patch)
tree958ab0bb65d6d7f672ce3518c4436c6eb6db540f /src
parentb0486007e33cadd006c65a99d4c87167ed18e59a (diff)
downloadopenbsd-b6d268488e8a9312eb674665715a44b1a6c599cf.tar.gz
openbsd-b6d268488e8a9312eb674665715a44b1a6c599cf.tar.bz2
openbsd-b6d268488e8a9312eb674665715a44b1a6c599cf.zip
have _THREAD_PRIVATE_MUTEX for DNS/YP/hosts lookup.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/getaddrinfo.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/libc/net/getaddrinfo.c b/src/lib/libc/net/getaddrinfo.c
index 4b02f8f106..364bffedeb 100644
--- a/src/lib/libc/net/getaddrinfo.c
+++ b/src/lib/libc/net/getaddrinfo.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getaddrinfo.c,v 1.39 2002/07/01 21:57:35 itojun Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.40 2002/07/24 01:38:34 itojun Exp $ */
2/* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */ 2/* $KAME: getaddrinfo.c,v 1.31 2000/08/31 17:36:43 itojun Exp $ */
3 3
4/* 4/*
@@ -108,6 +108,8 @@
108#include "ypinternal.h" 108#include "ypinternal.h"
109#endif 109#endif
110 110
111#include "thread_private.h"
112
111#define SUCCESS 0 113#define SUCCESS 0
112#define ANY 0 114#define ANY 0
113#define YES 1 115#define YES 1
@@ -500,6 +502,9 @@ getaddrinfo(hostname, servname, hints, res)
500/* 502/*
501 * FQDN hostname, DNS lookup 503 * FQDN hostname, DNS lookup
502 */ 504 */
505
506_THREAD_PRIVATE_MUTEX(getaddrinfo_explore_fqdn);
507
503static int 508static int
504explore_fqdn(pai, hostname, servname, res) 509explore_fqdn(pai, hostname, servname, res)
505 const struct addrinfo *pai; 510 const struct addrinfo *pai;
@@ -513,6 +518,8 @@ explore_fqdn(pai, hostname, servname, res)
513 char lookups[MAXDNSLUS]; 518 char lookups[MAXDNSLUS];
514 int i; 519 int i;
515 520
521 _THREAD_PRIVATE_MUTEX_LOCK(getaddrinfo_explore_fqdn);
522
516 result = NULL; 523 result = NULL;
517 524
518#if 0 525#if 0
@@ -521,15 +528,19 @@ explore_fqdn(pai, hostname, servname, res)
521 * return the address family or not. 528 * return the address family or not.
522 * XXX does not handle PF_UNSPEC case, should filter final result 529 * XXX does not handle PF_UNSPEC case, should filter final result
523 */ 530 */
524 if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai)) 531 if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(pai)) {
532 _THREAD_PRIVATE_MUTEX_UNLOCK(getaddrinfo_explore_fqdn);
525 return 0; 533 return 0;
534 }
526#endif 535#endif
527 536
528 /* 537 /*
529 * if the servname does not match socktype/protocol, ignore it. 538 * if the servname does not match socktype/protocol, ignore it.
530 */ 539 */
531 if (get_portmatch(pai, servname) != 0) 540 if (get_portmatch(pai, servname) != 0) {
541 _THREAD_PRIVATE_MUTEX_UNLOCK(getaddrinfo_explore_fqdn);
532 return 0; 542 return 0;
543 }
533 544
534 if ((_res.options & RES_INIT) == 0 && res_init() == -1) 545 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
535 strncpy(lookups, "f", sizeof lookups); 546 strncpy(lookups, "f", sizeof lookups);
@@ -560,6 +571,7 @@ explore_fqdn(pai, hostname, servname, res)
560 /* canonname should be filled already */ 571 /* canonname should be filled already */
561 } 572 }
562 *res = result; 573 *res = result;
574 _THREAD_PRIVATE_MUTEX_UNLOCK(getaddrinfo_explore_fqdn);
563 return 0; 575 return 0;
564 } else { 576 } else {
565 /* translate error code */ 577 /* translate error code */
@@ -591,6 +603,7 @@ explore_fqdn(pai, hostname, servname, res)
591free: 603free:
592 if (result) 604 if (result)
593 freeaddrinfo(result); 605 freeaddrinfo(result);
606 _THREAD_PRIVATE_MUTEX_UNLOCK(getaddrinfo_explore_fqdn);
594 return error; 607 return error;
595} 608}
596 609