This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 14/03/15 13:54, Joshua Rogers wrote: > On 14/03/15 05:43, Carlos O'Donell wrote: >>>> >> > Would that be what res_init() is for? >> > That function is intended to initialize the internals of the resolver. >> > That isn't what you're interested in doing though. You want to alter >> > the internals, and those internals might change. You have no option >> > but to keep modifying your code and recompiling if the internals of _res >> > change. >> > > I meant, run res_init() before we alter the internals. > Based on what you've said later on in this email, should I be doing > res_init(), then running __res_vinit() manually? > Yes, I believe I was right originally. Perhaps I didn't phrase my words correctly, though. From http://docstore.mik.ua/orelly/networking_2ndEd/dns/ch15_02.htm : "res_initint res_init(void)res_init reads resolv.conf and initializes a data structure called _res (more about that later). All the previously discussed routines will call res_init if they detect that it hasn't been called previously. Or you can call it on your own; this is useful if you want to change some of the defaults before calling the first resolver library routine. If there are any lines in resolv.conf that res_init doesn't understand, it ignores them. res_init always returns zero, even if the manpage reserves the right to return -1." The important part being: "Or you can call it on your own; this is useful if you want to change some of the defaults before calling the first resolver library routine. " However, this does not seem to be the case. Even using res_* family only, for exampe: http://codepad.org/55rsDQjZ On line 34, res_init() is called, so that should initalize the _res structure. On lines 36 and 37, we overwrite _res.nscount and _res.nsaddr_list[0]. HOwever, on the res_query call on line 46, the _res structure is reset. If we uncomment L26-28, and comment L34, res_query correctly uses _res with the custom nsaddr, and does NOT reset _res. So, to me, this seems like a bug in res_init(), not setting something to indicate that it indeed has been initialized.. Or that orielly book is wrong. Using the code: if(_res.options & RES_INIT) { printf("RES_INIT set.\n"); } else { printf("RES_INIT not set.\n"); } after res_init, indicates RES_INIT is indeed set. Thanks, -- -- Joshua Rogers <https://internot.info/>
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |