diff options
author | marc <> | 2003-01-28 04:58:00 +0000 |
---|---|---|
committer | marc <> | 2003-01-28 04:58:00 +0000 |
commit | 547ebab319b228b064cf5dcb3ff0ae1bf23d24a2 (patch) | |
tree | f57454716593fb3b68672505c6dccab6438498f1 /src/lib/libc/net/sethostent.c | |
parent | 98a78d57b176408b5aca87705f9681c5b155b47c (diff) | |
download | openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.gz openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.tar.bz2 openbsd-547ebab319b228b064cf5dcb3ff0ae1bf23d24a2.zip |
thread safer libc (note: safer, not safe)
Access to the global _res structure replaced by pointers to a
per thread instance. If unthreaded the pointer is to the
global structure.
Also replaced a 64k stack array with malloc-ed memory so
threaded aps (with a default 64k stack) have a chance at working.
ok deraadt@
Diffstat (limited to 'src/lib/libc/net/sethostent.c')
-rw-r--r-- | src/lib/libc/net/sethostent.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libc/net/sethostent.c b/src/lib/libc/net/sethostent.c index 5392a2f11b..40a5a80962 100644 --- a/src/lib/libc/net/sethostent.c +++ b/src/lib/libc/net/sethostent.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char rcsid[] = "$OpenBSD: sethostent.c,v 1.4 1997/03/15 21:53:50 pefo Exp $"; | 35 | static char rcsid[] = "$OpenBSD: sethostent.c,v 1.5 2003/01/28 04:58:00 marc Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> |
@@ -41,20 +41,25 @@ static char rcsid[] = "$OpenBSD: sethostent.c,v 1.4 1997/03/15 21:53:50 pefo Exp | |||
41 | #include <netdb.h> | 41 | #include <netdb.h> |
42 | #include <resolv.h> | 42 | #include <resolv.h> |
43 | 43 | ||
44 | #include "thread_private.h" | ||
45 | |||
44 | void | 46 | void |
45 | sethostent(stayopen) | 47 | sethostent(stayopen) |
46 | int stayopen; | 48 | int stayopen; |
47 | { | 49 | { |
50 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
48 | 51 | ||
49 | if ((_res.options & RES_INIT) == 0 && res_init() == -1) | 52 | if ((_resp->options & RES_INIT) == 0 && res_init() == -1) |
50 | return; | 53 | return; |
51 | if (stayopen) | 54 | if (stayopen) |
52 | _res.options |= RES_STAYOPEN | RES_USEVC; | 55 | _resp->options |= RES_STAYOPEN | RES_USEVC; |
53 | } | 56 | } |
54 | 57 | ||
55 | void | 58 | void |
56 | endhostent() | 59 | endhostent() |
57 | { | 60 | { |
58 | _res.options &= ~(RES_STAYOPEN | RES_USEVC); | 61 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); |
62 | |||
63 | _resp->options &= ~(RES_STAYOPEN | RES_USEVC); | ||
59 | res_close(); | 64 | res_close(); |
60 | } | 65 | } |