From owner-freebsd-hackers Mon Aug 9 22:44:53 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from xylan.com (postal.xylan.com [208.8.0.248]) by hub.freebsd.org (Postfix) with ESMTP id A1C7115371 for ; Mon, 9 Aug 1999 22:44:45 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from mailhub.xylan.com by xylan.com (8.8.7/SMI-SVR4 (xylan-mgw 2.2 [OUT])) id WAA03329; Mon, 9 Aug 1999 22:43:14 -0700 (PDT) Received: from omni.xylan.com by mailhub.xylan.com (SMI-8.6/SMI-SVR4 (mailhub 2.1 [HUB])) id WAA19417; Mon, 9 Aug 1999 22:38:46 -0700 Received: from softweyr.com ([204.68.178.39]) by omni.xylan.com (4.1/SMI-4.1 (xylan engr [SPOOL])) id AA15506; Mon, 9 Aug 99 22:43:09 PDT Message-Id: <37AFBBEC.7E078E26@softweyr.com> Date: Mon, 09 Aug 1999 23:43:08 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 3.1-RELEASE i386) X-Accept-Language: en Mime-Version: 1.0 To: ognir@humboldt1.com Cc: dan@trinsec.com, hackers@FreeBSD.ORG Subject: Re: gethostbyaddr() and threads. References: <199908100116.SAA02821@home.humboldt1.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Joe Groff wrote: > > ---Dan Moschuk said: > > > > | Well, I guess we might as well change the API, since everyone else does. > > Unless > > | someone comes up with a bettter idea, of course :) > > | > > | -Joe > > > > The API should not change. There is already enough descrepency between UNIXs > > to warrant programs like autoconf, we should not introduce another. > > We should introduce a gethostbyaddr_r function, which shouldn't be all that > > though to implement. > That's what I meant by an API change. Sorry for not being clearer. > However, if you can roll in reentrancy without having to add the _r > functions, that would save some sweat on the programmers' side. No, it wouldn't, because any existing programs that already handle name server queries within threads will already use the gethostby*_r APIs. > >>From the code that I looked at today, the problems lie inside of glibc. It > > declares globally a few static variables that are used by the gethost* > > functions. Obviously in a threaded environment, this is bad. > > > > A nice fix would be to get rid of those variables entirely. A quicker fix > > would be just to enclose those global variables in mutexes. Personally, I > > like the nicer fix better, which will (unfortunately) involve rewriting most > > of the frontends to the res_* functions. > > > > If no one has any objections, I'd like to start on this tomorrow. > > > Go for it! Someone needs to. :) Here are the prototypes. Hosts: #include #include #include #include #include struct hostent *gethostbyname_r(const char *name, struct hostent *result, char *buffer, int buflen, int *h_errnop); struct hostent *gethostbyaddr_r(const char *addr, int length, int type, struct hostent *result, char *buffer, int buflen, int *h_errnop); struct hostent *gethostent_r(struct hostent *result, char *buffer, int buflen, int *h_errnop); Nets: #include struct netent *getnetbyname_r(const char *name, struct netent *result, char *buffer, int buflen); struct netent *getnetbyaddr_r(long net, int type, struct netent *result, char *buffer, int buflen); struct netent *getnetent_r(struct netent *result, char *buffer, int buflen); Protocols: #include struct protoent *getprotobyname_r(const char *name, struct protoent *result, char *buffer, int buflen); struct protoent *getprotobynumber_r(int proto, struct protoent *result, char *buffer, int buflen); struct protoent *getprotoent_r(struct protoent *result, char *buffer, int buflen); Services: #include struct servent *getservbyname_r(const char *name, const char *proto, struct servent *result, char *buffer, int buflen); struct servent *getservbyport_r(int port, const char *proto, struct servent *result, char *buffer, int buflen); struct servent *getservent_r(struct servent *result, char *buffer, int buflen); RPC services: #include struct rpcent *getrpcbyname_r(const char * name, struct rpcent *result, char *buffer, int buflen); struct rpcent *getrpcbynumber_r(const int number, struct rpcent *result, char *buffer, int buflen); struct rpcent *getrpcent_r(struct rpcent *result, char *buffer, int buflen); Any questions? -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC http://softweyr.com/ wes@softweyr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message