AOL Webserver - Ns_DriverInit should not call gethostbyname directly?

This is Interesting: Free IT Magazines  
Home > Archive > AOL Webserver > October 2007 > Ns_DriverInit should not call gethostbyname directly?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Ns_DriverInit should not call gethostbyname directly?
Andrew Piskorski

2007-10-22, 1:11 pm

Hm, this is minor, but I notice that Ns_DriverInit() calls the
(non-thread-safe) gethostbyname() and gethostbyaddr() directly:

$ find . -name "*.c" -print | xargs egrep -n '(gethostbyname|gethostbyaddr)'
./driver.c:261: he = gethostbyname(host ? host : Ns_InfoHostname());
./driver.c:274: he = gethostbyaddr(he->h_addr, he->h_length, he->h_addrtype);

SF bug #1008721 (closed since 2004) says that's ok, no danger:

http://sourceforge.net/tracker/inde...152&atid=103152

AOLserver uses gethostbyname() in two places - once
in nsd/driver.c at server start-up, which is safe since
we're only running one thread in the config interp at
that time.

But, why call these non-thread-safe functions there, rather than
Ns_GetAddrByHost() and Ns_GetHostByAddr()?

Alos, if we do keep the use of gethostbyname(), ideally someone would
add a comment saying why, and that it's safe, like Dossy explained in
that old ticket.

--
Andrew Piskorski <atp@piskorski.com>
http://www.piskorski.com/


Dossy Shiobara

2007-10-22, 1:11 pm

On 2007.10.22, Andrew Piskorski <atp@PISKORSKI.COM> wrote:
> But, why call these non-thread-safe functions there, rather than
> Ns_GetAddrByHost() and Ns_GetHostByAddr()?


Good question! Without looking too deeply at the code, the two
functions you reference uses mutexes and caches--things that I don't
believe are initialized at the early time of Ns_DriverInit's invoking.

I haven't actually researched this, so I could be totally wrong.

> Alos, if we do keep the use of gethostbyname(), ideally someone would
> add a comment saying why, and that it's safe, like Dossy explained in
> that old ticket.


Feel free to copy my explanation into the source as a comment, if you
feel it's valuable to do so.

-- Dossy

--
Dossy Shiobara | dossy@panoptic.com | http://dossy.org/
Panoptic Computer Network | http://panoptic.com/
"He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on." (p. 70)


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com