From 547ebab319b228b064cf5dcb3ff0ae1bf23d24a2 Mon Sep 17 00:00:00 2001 From: marc <> Date: Tue, 28 Jan 2003 04:58:00 +0000 Subject: 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@ --- src/lib/libc/net/sethostent.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/lib/libc/net/sethostent.c') 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 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: sethostent.c,v 1.4 1997/03/15 21:53:50 pefo Exp $"; +static char rcsid[] = "$OpenBSD: sethostent.c,v 1.5 2003/01/28 04:58:00 marc Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -41,20 +41,25 @@ static char rcsid[] = "$OpenBSD: sethostent.c,v 1.4 1997/03/15 21:53:50 pefo Exp #include #include +#include "thread_private.h" + void sethostent(stayopen) int stayopen; { + struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); - if ((_res.options & RES_INIT) == 0 && res_init() == -1) + if ((_resp->options & RES_INIT) == 0 && res_init() == -1) return; if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; + _resp->options |= RES_STAYOPEN | RES_USEVC; } void endhostent() { - _res.options &= ~(RES_STAYOPEN | RES_USEVC); + struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); + + _resp->options &= ~(RES_STAYOPEN | RES_USEVC); res_close(); } -- cgit v1.2.3-55-g6feb