|
/
Zope
/
Apsis
/
Pound Mailing List
/
Archive
/
2004
/
2004-10
/
is inet_ntoa thread save?
[
Feature Request / Alexander Lazic ... ]
[
Config question HTTPSHeaders / Thierry Coopman ... ]
is inet_ntoa thread save?
Tom Anheyer <Tom.Anheyer(at)berlinonline.de> |
2004-10-05 17:12:40 |
[ FULL ]
|
Hi,
I found many uses of inet_ntoa() in the pound sources. Maybe this funktion is
not thread save. From the manpage:
The inet_ntoa() function converts the Internet host address in given in
network byte order to a string in standard numbers-and-dots notation.
The string is returned in a statically allocated buffer, which subse-
quent calls will overwrite.
Using inet_ntop() shouldt be better. Is this correct?
tom anheyer
[...]
|
|
|
Re: is inet_ntoa thread save?
Robert Segall <roseg(at)apsis.ch> |
2004-10-05 17:40:37 |
[ FULL ]
|
On Tuesday 05 October 2004 17.12, Tom Anheyer wrote:[...]
You are right that inet_ntoa(3) is not thread-safe, but the issue is hardly
critical - it is used exclusively for printing out stuff and it seems to work
"well enough".
I would be happy to switch to inet_ntop(3), but I am not sure how widespread
it is: at least on *BSD it seems to be part of the Linux compatability
package. I don't really know about other systems, but I would be happy to
hear from other list members: does YOUR system support it out of the box?[...]
|
|
|
Re[2]: is inet_ntoa thread save?
Dmitry Dvoinikov <dmitry(at)targeted.org> |
2004-10-06 05:24:00 |
[ FULL ]
|
> at least on *BSD it seems to be part of the Linux compatability[...]
Just tried it on the FreeBSD 4.10 - inet_ntop seems to be working
right out of the box, w/o any linux compatibility layer turned on.
Sincerely,
Dmitry Dvoinikov
http://www.targeted.org/
--- Original message follows ---
[...][...]
[...]
[...]
|
|
|
RE: Re[2]: is inet_ntoa thread save?
=?iso-8859-2?Q?J=F3zsef_N=E9meth?= <Jozsef.Nemeth(at)levnor.hu> |
2004-10-06 13:16:50 |
[ FULL ]
|
[...]
IMHO on OpenBSD 3.4 working too without linux compatibility...
The inet_ntop used in the base system:
# grep -rn inet_ntop /sbin/*
Binary file /sbin/dhclient matches
Binary file /sbin/dump matches
Binary file /sbin/ifconfig matches
... etc.
Jozsef Nemeth
Levnor Ltd.
Hungary
|
|
|
RE: Re[2]: is inet_ntoa thread save?
"Mark Fontana" <mark.fontana(at)efi.com> |
2004-10-06 18:19:42 |
[ FULL ]
|
Robert Segall wrote:
[...]
work[...]
I disagree that this is unimportant. If an implementation of inet_ntoa()
DOES use a static buffer, and it happens to be written to by one thread while
being read by another, there is the potential that the buffer might not be
NULL-terminated, causing pound to run off the end of the buffer while
printing
and possibly print garbage, cause a segfault, etc.
Now, I have never seen these problems occur under Linux, even with pound
under
heavy load with copious logging. I believe this is because glibc includes
code to ensure that static buffers for functions such as gethostbyname() and
inet_ntoa() are created on a per-thread basis (as opposed to a single global
static buffer shared by all threads). But it is possible that C libraries on
other platforms may not be so helpful about this matter, so I would recommend
considering the suggested changeover to inet_ntop().
Mark Fontana
|
|
|
|