Steven Johnson sjohnson at
Thu Oct 19 09:02:08 UTC 2006


Please consider the attached patch.

It adds a functional gethostbyname_r to rtems.  We were having problems 
with multiple threads calling gethostbyname, so we decided the best way 
to deal with it was to do it properly, rather than kludge up our code to 
make gethostbyname safe.

We have found several slightly different parameter lists for this 
function, it doesn't seem to be standard. The one we used has the linux 
interface.  In rtems there was an existing gethostbyname_r inside a 
"#ifdef _THREAD_SAFE" which was NOT Threadsafe, as this just called 
gethostbyname. So we have placed all of the additional code inside the 
#ifdef _THREAD_SAFE.

The code mainly came from COMOS a no license project available from 
sourceforge. Our main change was to read the hosts file in a similar way 
to the current rtems gethostent, instead of the original which used mmap.

We have tested it looking up 2 addresses in different threads at the 
same time and we have tested looking in the hosts file (localhost). We 
have also tested outside of our subnet.

This patch is against

Best Regards,
Steven Johnson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtems-
Type: text/x-patch
Size: 10687 bytes
Desc: not available
URL: <>

More information about the users mailing list