_res value related query

View: New views
4 Messages — Rating Filter:   Alert me  

_res value related query

by Channa-2 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

I have a query with respect to '_res' resolver state in NetBSD.
Which is define in resolv.h as

$ cat include/resolv.h

:
#define _res (*__res_state())
:

The have the following test case.

#include <stdio.h>
#include <resolv.h>
#include <netdb.h>

int main(int argc,char *argv[])
{
  printf("The _res value is %d\n",_res);

  return 0 ;
}

when executed gives the following output:

$ ./test
The _res value is 5

It always prints the value '5'.
Could anyone tell me why the value 5??

Thanks & Regards,
Channa

Re: _res value related query

by Christos Zoulas-2 :: Rate this Message:

| View Threaded | Show Only this Message

In article <515c64960903100429m6cce52bje2c0d8cf14cbb30b@...>,
Channa  <channa.kad@...> wrote:

>Hi,
>
>I have a query with respect to '_res' resolver state in NetBSD.
>Which is define in resolv.h as
>
>$ cat include/resolv.h
>
>:
>#define _res (*__res_state())
>:
>
>The have the following test case.
>
>#include <stdio.h>
>#include <resolv.h>
>#include <netdb.h>
>
>int main(int argc,char *argv[])
>{
>  printf("The _res value is %d\n",_res);
>
>  return 0 ;
>}
>
>when executed gives the following output:
>
>$ ./test
>The _res value is 5
>
>It always prints the value '5'.
>Could anyone tell me why the value 5??

The first value of the struct is retrans which is set to RES_TIMEOUT.

christos


Re: _res value related query

by Channa-2 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

Yes, thank you very much.
I have one doubt regarding '_res' state.
In the functions '__res_get_state_nothread(void)'
in res_init.c the initialization is taken care using res_ninit().

Is it really required for '_res' to be initialized in the library? or
User application
should take care of initializing?

Is there any specification which says _res has to be initialized?

Hope my doubt makes some sense to you.

Thanks in Advance,
Channa

On 11/03/2009, Christos Zoulas <christos@...> wrote:

> In article <515c64960903100429m6cce52bje2c0d8cf14cbb30b@...>,
>
> Channa  <channa.kad@...> wrote:
>  >Hi,
>  >
>  >I have a query with respect to '_res' resolver state in NetBSD.
>  >Which is define in resolv.h as
>  >
>  >$ cat include/resolv.h
>  >
>  >:
>  >#define _res (*__res_state())
>  >:
>  >
>  >The have the following test case.
>  >
>  >#include <stdio.h>
>  >#include <resolv.h>
>  >#include <netdb.h>
>  >
>  >int main(int argc,char *argv[])
>  >{
>  >  printf("The _res value is %d\n",_res);
>  >
>  >  return 0 ;
>  >}
>  >
>  >when executed gives the following output:
>  >
>  >$ ./test
>  >The _res value is 5
>  >
>  >It always prints the value '5'.
>  >Could anyone tell me why the value 5??
>
>
> The first value of the struct is retrans which is set to RES_TIMEOUT.
>
>
>  christos
>
>

Re: _res value related query

by Christos Zoulas :: Rate this Message:

| View Threaded | Show Only this Message

On Mar 12, 11:25am, channa.kad@... (Channa) wrote:
-- Subject: Re: _res value related query

| Hi,
|
| Yes, thank you very much.
| I have one doubt regarding '_res' state.
| In the functions '__res_get_state_nothread(void)'
| in res_init.c the initialization is taken care using res_ninit().
|
| Is it really required for '_res' to be initialized in the library? or
| User application
| should take care of initializing?
|
| Is there any specification which says _res has to be initialized?
|
| Hope my doubt makes some sense to you.
|
| Thanks in Advance,
| Channa

These days you should not use the global _res. You should be creating
and initializing one with res_ninit().

christos