Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Jul 2000 00:39:18 +0800
From:      "Tan Juay Kwang" <tanjk@i-dns.net>
To:        "Richard Seaman, Jr." <dick@tar.com>
Cc:        <freebsd-questions@FreeBSD.ORG>
Subject:   RE: pthreads on 4.0-STABLE
Message-ID:  <NEBBLKHLGDECFCNMHPEEOEAMCPAA.tanjk@i-dns.net>
In-Reply-To: <20000720162831.B404@tar.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
>
> AFAIK, FreeBSD's implementation of gethostbyname is not thread safe,
> though I haven't studied it in detail, so its possible I'm wrong.
> What happens if you wrap your calls to gethostbyname() with a mutex?
> Does it work then?
>

I'm not tried this approach but even if it does work, it will means that
my gethostbyname are done serially, which is not what I really want.

> In general, the specs I've seen (eg SUSv2) also stipulate that
> even if gethostbyname is "thread safe" it can return a pointer
> to a static data structure.  So, if you're going to use it in
> multiple threads, and you want to be portable, you really need
> to wrap gethostbyname() in a mutex even if its "thread safe" so
> you use the returned pointer before releasing the mutex.  Otherwise
> some other thread can stomp on the static structure before you
> use it.
>

I see. Well, I guess the best thing I can do is to send out DNS packet
myself then, without going through kernel services.

> Ideally, a threads package will provide gethostbyname_r, where you
> pass a buffer for the result so you can avoid having to wrap the
> call in a mutex.  Unfortunately, I don't see this call in the
> FreeBSD user threads package.  Such a call does exist in linuxthreads
> (as well as the FreeBSD linuxthreads port --
>  see /usr/ports/devel/linuxthreads).
>
>

Right, will definitely check out the port, thanks.

Best regards,
Juay Kwang

[-- Attachment #2 --]
0	*H
010	+0	*H
*0.0v.=}%]
u0
	*H
0_10	UUS10U
VeriSign, Inc.1705U.Class 1 Public Primary Certification Authority0
980512000000Z
080512235959Z010U
VeriSign, Inc.10UVeriSign Trust Network1F0DU=www.verisign.com/repository/RPA Incorp. By Ref.,LIAB.LTD(c)981H0FU?VeriSign Class 1 CA Individual Subscriber-Persona Not Validated00
	*H
0ZDUz-Ox6
JoTw*h1ApzKHV-BD\B/;'
]6B3nTOJƚj$e~7jJ	|0z0	`HB0GU @0>0<`HE0-0++www.verisign.com/repository/RPA0U00U0
	*H
7;ڔ7qjm/d8[jI}g-,ݚB>V*3ǾSLýIBc¦]XI<\Ue  _Xj<n00]#
OF5}$;0
	*H
010U
VeriSign, Inc.10UVeriSign Trust Network1F0DU=www.verisign.com/repository/RPA Incorp. By Ref.,LIAB.LTD(c)981H0FU?VeriSign Class 1 CA Individual Subscriber-Persona Not Validated0
000628000000Z
000827235959Z010U
VeriSign, Inc.10UVeriSign Trust Network1F0DU=www.verisign.com/repository/RPA Incorp. by Ref.,LIAB.LTD(c)9810UPersona Not Validated1&0$UDigital ID Class 1 - Netscape10UJuay Kwang Tan10	*H
	tanjk@i-dns.net00
	*H
0շN^_I_lXxR_!XG])2!cOL9JKW%ҫԦN4ܷ{,MrUmDZqfkH|%g00	U00DU =0;09`HE0*0(+https://www.verisign.com/rpa0	`HB03U,0*0(&$"http://crl.verisign.com/class1.crl0
	*H
F0W9yXDк4@|FPF6lAR^*ͦ6<UY)Oq"7r2NFwzda_2N֊Fj!iQt$L<>0	JHz=S318040010U
VeriSign, Inc.10UVeriSign Trust Network1F0DU=www.verisign.com/repository/RPA Incorp. By Ref.,LIAB.LTD(c)981H0FU?VeriSign Class 1 CA Individual Subscriber-Persona Not Validated#
OF5}$;0	+0	*H
	1	*H
0	*H
	1
000721163918Z0#	*H
	1ߍ<p/T0h_0X	*H
	1K0I0
*H
0*H
0+0
*H
(0+0
*H
0	+710010U
VeriSign, Inc.10UVeriSign Trust Network1F0DU=www.verisign.com/repository/RPA Incorp. By Ref.,LIAB.LTD(c)981H0FU?VeriSign Class 1 CA Individual Subscriber-Persona Not Validated#
OF5}$;0
	*H
qtU#
e3~LOpzq*VݰxTK2SiN%#jlAlāߒ#G\w
$rs. k1)y"e*Wsft
˜b

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?NEBBLKHLGDECFCNMHPEEOEAMCPAA.tanjk>