Why is getaddrinfo breaking POSIX?

Previous thread: Infos Sportnco : Pariez sur une victoire de Marseille ce soir contre le Real ! by Sportnco on Tuesday, December 8, 2009 - 5:04 am. (1 message)

Next thread: Workathomesystem[2807] sent you a message from LATET by HRdepartment2807 on Tuesday, December 8, 2009 - 6:48 am. (1 message)
From: Jonathan Schleifer
Date: Tuesday, December 8, 2009 - 6:44 am

Just wondering: Why is getaddrinfo breaking POSIX by not being thread- 
safe and what is the thread-safe alternative to it? (Please don't tell  
me to use locks, as that would kill the possibility to lookup multiple  
hosts at once).

I consider it very strange that an OS still has a thread-unsafe  
getaddrinfo in the year 2009, even though POSIX and RFC 2553 both  
require it to be thread-safe. And it makes it especially hard to write  
portable applications, as there is no way to check if getaddrinfo is  
thread-safe in a configure script.

--
Jonathan

From: Otto Moerbeek
Date: Tuesday, December 8, 2009 - 7:41 am

Nobody did the work yet. If it's very important to you, consider
spending effort making it thread safe. I believe netbsd and freebsd
have thread safe implementations. But actullay verifying that is
pretty hard.

	-Otto

From: Bret Lambert
Date: Tuesday, December 8, 2009 - 7:52 am

The existing resolver code is compleat balls, as oga@ would spell it.
Frankly, it needs to be dragged behind the chemical sheds and

From: Jonathan Schleifer
Date: Wednesday, December 9, 2009 - 2:55 am

Wouldn't it be possible to at least put a lock around it, so that at  
least it does not produce bogus lookups, but is does sequentiel but  
correct lookups instead? This would at least not break POSIX and would  
be compatible to thread-safe implementations, though slower than  
thread-safe implementations. It would already be a big relieve for  
programmers if they can just use getaddrinfo and know that they at  
least get a correct result on any OS. ATM, I have to do a whitelist of  
operating systems that are known to have thread-safe implementations  
and do a lock for the others.

--
Jonathan

From: Bret Lambert
Date: Wednesday, December 9, 2009 - 2:59 am

On Wed, Dec 9, 2009 at 10:55 AM, Jonathan Schleifer


From: Jonathan Schleifer
Date: Wednesday, December 9, 2009 - 2:56 am

Yes, the NetBSD implementation is thread-safe since 4.0. For FreeBSD,  
I don't know since which version it is thread-safe, but it's thread- 
safe in recent versions.

For the verifying part: If the implementation has no side-effects  
(like modifying some global variable that is not per-thread), the  
implementation is thread-safe.

--
Jonathan

From: Bret Lambert
Date: Wednesday, December 9, 2009 - 3:07 am

On Wed, Dec 9, 2009 at 10:56 AM, Jonathan Schleifer


From: Otto Moerbeek
Date: Wednesday, December 9, 2009 - 3:29 am

Thank you for your lesson. We're lucky we have a very helpful community.

I still hope that this mailing thread has the nice side-effect of
getting us a verified thread-safe getaddrinfo implementation. 

	-Otto

Previous thread: Infos Sportnco : Pariez sur une victoire de Marseille ce soir contre le Real ! by Sportnco on Tuesday, December 8, 2009 - 5:04 am. (1 message)

Next thread: Workathomesystem[2807] sent you a message from LATET by HRdepartment2807 on Tuesday, December 8, 2009 - 6:48 am. (1 message)