[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gethostbyname_r is not thread-safe
From: |
Rei Takahashi |
Subject: |
gethostbyname_r is not thread-safe |
Date: |
Wed, 10 Jul 2002 23:21:02 +0900 |
Hello
Please allow my poor English.(I'm Japanese)
In glibc-2.2.5, I get this message while running multi-threaded program.
> /etc/host.conf: line 1: cannot specify more than 4 services
In my survey, I think that 'gethostbyname_r()' has a little bug.
'gethostbyname_r()' is implemented in 'nss/getXXbyYY_r.c'.
'_res_hconf' is GLOBAL-variable, but
> #ifdef NEED__RES_HCONF
> if (!_res_hconf.initialized)
> _res_hconf_init ();
> #endif /* need _res_hconf */
is not locked!
It causes call '_res_hconf_init()' two or more times concurrently.
This occurs first-call 'gethostbyname_r' by process, so this problem is
rare.
(So, I can avoid it by calling dummy 'gethostbyname_r()' before creating
thread.)
This causes executing
> _res_hconf.service[_res_hconf.num_services++] = service;
concurrently, and
> if (_res_hconf.num_services >= SERVICE_MAX)
makes be true, so I get that message.(resolv/res_hconf.c)
Please fix it if you can get my explanation.
--
Rei Takahashi
Future Spirits Co.,Ltd. / Japan
- gethostbyname_r is not thread-safe,
Rei Takahashi <=