[Wifidog] thread unsafe calls

David Vincelli rmx at bellnet.ca
Fri Oct 22 23:00:59 EDT 2004

On Fri, Oct 22, 2004 at 09:06:46PM -0400, Alexandre Carmel-Veilleux wrote:
> On Fri, Oct 22, 2004 at 09:10:03PM -0400, David Vincelli wrote:
> > 
> > I was just taking a look at wifidog's thread functions again.
> > I see in ping_thread.c, a call to gethostbyname(), according to the
> > pthreads man page (openbsd) this call is not thread safe.
> 	Alternative #2, a wrapper function with a mutex.
> 	I'll write this and check it in.

Good, hope it helps.

> > Also, minor and probably irrelevant detail: snprintf() returns -1 on
> > error or the size of the string pasted in the buffer if succesful.
> > You guys aren't doing any error checking. It might be important.
> > You never know, especially on an embedded platform with "limited"
> > capacity.
> 	snprintf() should never return -1. It should return the total
> number of characters copied into the string. asprintf() returns -1 when
> malloc fails. Or so says the Darwin man pages.

You're right - I'm wrong. I misread the man page. OpenBSD man page 
says it returns the size of the string -1 (\0) or the size that it
would've been had it had enough space to allocate it. Then it goes 
on to say that it returns -1 in case of error. It's a slightl 
ambiguous, check the man page on the project's web site if you want.
After re-reading the related blurb, I think it means it should never
return -1.


Wifidog mailing list
Wifidog at isf.waglo.com

More information about the Wifidog mailing list