On 02/03/2010 07:09, Dan Mick wrote:
On 03/ 1/10 08:58 AM, Robert Milkowski wrote:
On 01/03/2010 15:40, Robert Milkowski wrote:
On 26/02/2010 00:52, Shawn Walker wrote:
On 02/25/10 06:03 PM, Robert Milkowski wrote:
Hi,

mi...@vault:~$ cat dns.c

#include<stdlib.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<arpa/nameser.h>
#include<resolv.h>
#include<netdb.h>

int main(int argc, char **argv)
{
res_init();
if (!_res.nscount) {
fprintf(stderr,"No nameservers defined.\n");
exit(1);
}
}


mi...@vault:~$ gcc -o dns -lresolv -lsocket -lnsl dns.c
...
it works fine on b111 but fails on b132 and b133 (I haven't tested
any other builds).

Did you check _res.res_h_errno? I would note that res_init() is
deprecated.

If an error is encountered during res_init()'s initial logic, it will
effectively set nscount to 0 because it sets maxns = 0. [1]


well, _res.res_h_errno is returning with 0 while nscount is 0 as well.
deprecated or not that's what some programs are using (like mtr) and
something changed post 111b so it stopped working.

I could get mtr fixed but really the problem has to be founded as it
might impact other programs too.
Will try to dig more deeply once I've got some time.


I think I found where the issue is.
On 11th of November 2009 there was an integration of 11038:74b12212b8a2
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libresolv2/common/resolv/res_data.c?r=11038%3A74b12212b8a2>




It introduced changes to
/onnv/onnv-gate/usr/src/lib/libresolv2/common/resolv/res_data.c
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libresolv2/common/resolv/res_data.c>


http://src.opensolaris.org/source/diff/onnv/onnv-gate/usr/src/lib/libresolv2/common/resolv/res_data.c?r2=%252Fonnv%252Fonnv-gate%252Fusr%252Fsrc%252Flib%252Flibresolv2%252Fcommon%252Fresolv%252Fres_data.c%4011038%3A74b12212b8a2&r1=%252Fonnv%252Fonnv-gate%252Fusr%252Fsrc%252Flib%252Flibresolv2%252Fcommon%252Fresolv%252Fres_data.c%400%3A68f95e015346


In particular it added below three lines:

94#if defined(DO_PTHREADS) || defined(__linux)
95#define _res (*__res_state())
96#endif
97

If I comment them out and LD_PRELOAD libresolve.so.2 library then my
test program works fine.

So looks like the above change broke the old behavior.

It looks to me like the problem is that no one defines _REENTRANT in
the 'normal' include of resolv.h, which would turn on the new "_res is
a function call to get thread-local storage" that libresolv.so.2 is
compiled to use.
If you add #define _REENTRANT 1 to your code, it seems to work.

I agree this seems to be a bug.


Looks like it has been fixed.

http://mail.opensolaris.org/pipermail/onnv-notify/2010-April/011832.html
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to