Skip to contentSkip to conversation

resolver_r.3: New page documenting res_ninit() et al

PATCH/RFC Jonathan Nieder 2 participants 6 messages Jul 4, 2011 – Jul 5, 2011 2 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

Readers learning about the glibc resolver implementation might appreciate some documentation for these basic functions. They are reentrant analogues invented by vixie around 1998 (?) for the traditional BSD res_* functions.

The BIND 8 changelog (item 384) says:

there is now a nearly-thread-safe resolver API, with the old non-thread-safe API being a set of stubs on top of this. it is possible to program without _res.
note: the documentation has not been updated. also
note: IRS is a thread-ready API, get*by*() is not. (see ../contrib/manyhosts for an example application.)

Luckily the glibc source tree includes some documentation for these functions by Mark Kettenis at resolv/README, under the heading "Using the resolver in multi-threaded code". Steal that text, and with minimal changes make it into a manpage.

To avoid requiring yet another license document to be distributed with man-pages, the new manpage uses GPL-2+ as its license instead of glibc's LGPL-2.1+.

---
Hi,

While looking over the glibc resolver code, I started to wish some documentation like this existed. As mentioned above, the text is mostly stolen from glibc's resolv/README. What do you think? Improvements? Simplifications?

Maybe the license should be something like "LGPL-2.1+ or (at your option) GPL-2+" instead.

 man3/res_ninit.3        |    1 +
 man3/res_nmkquery.3     |    1 +
 man3/res_nquery.3       |    1 +
 man3/res_nquerydomain.3 |    1 +
 man3/res_nsearch.3      |    1 +
 man3/res_nsend.3        |    1 +
 man3/resolver.3         |    1 +
 man3/resolver_r.3       |  136 +++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 143 insertions(+), 0 deletions(-)
 create mode 100644 man3/res_ninit.3
 create mode 100644 man3/res_nmkquery.3
 create mode 100644 man3/res_nquery.3
 create mode 100644 man3/res_nquerydomain.3
 create mode 100644 man3/res_nsearch.3
 create mode 100644 man3/res_nsend.3
 create mode 100644 man3/resolver_r.3
man3/res_ninit.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/res_nmkquery.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/res_nquery.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/res_nquerydomain.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/res_nsearch.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/res_nsend.3 new file +1 -0
new file mode 100644
index 00000000..9963b525
@@ -0,0 +1 @@
+.so man3/resolver_r.3
man3/resolver.3 +1 -0
index a72dde7b..44f8f902 100644
@@ -261,6 +261,7 @@ of the compressed name, or \-1 if an error occurs.
 .SH "CONFORMING TO"
 4.3BSD.
 .SH "SEE ALSO"
+.BR resolver_r (3),
 .BR gethostbyname (3),
 .BR resolv.conf (5),
 .BR resolver (5),
man3/resolver_r.3 new file +136 -0

136 lines not on this page · raw message

Signature · 6 lines
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Hi again,

Quoted 3 lines · Jonathan Nieder
man3/resolver_r.3 new file +0 -0
@@ -0,0 +1,136 @@

[...]

Quoted 1 line

+.B typedef struct state *res_state;

Looking over [1], it occurs to me that treating "res_state" as an opaque type doesn't work if this API is to be actually usable. A typical program will look like this:

	struct __res_state res;

	if (res_ninit(&res))
		die_errno("cannot initialize resolver");
	...

Is "struct __res_state" really supposed to be part of the public API? I guess it is.

So I'd suggest squashing in the mini-patch below to reflect that. Sorry for the noise.

[1] https://lists.isc.org/pipermail/bind-users/2008-July/070847.html

---
 man3/resolver_r.3 |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
man3/resolver_r.3 +2 -1
index f2ced438..a70834b4 100644
@@ -13,7 +13,8 @@ res_nsend \- reentrant resolver routines
 .nf
 .B #include <resolv.h>
 .sp
-.B typedef struct state *res_state;
+.B struct __res_state;
+.B typedef struct __res_state *res_state;
 .sp
 .BI "int res_ninit(res_state " statep ");"
 .sp
Signature · 6 lines
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi,

IIRC bind 8 (or libbind) also comes with its own manpages. Ages ago I stole the info from their resolver.3 page and merged it with the page distributed with glibc (the current version is taken from there as well, IIRC). The patch got somehow lost through the cracks, I think...

Or do you see any licensing issues with doing that?

OTOH, if you want to keep your approach and add another page for the reentrant functions, you might want to add a pointer in resolver.3 so people know there's another page as well :).

Just my 2 cents,
Stefan.

Quoted 50 lines · Jonathan Nieder

Hi again,

Quoted 3 lines · Jonathan Nieder
man3/resolver_r.3 new file +0 -0
@@ -0,0 +1,136 @@

[...]

Quoted 1 line

+.B typedef struct state *res_state;

Looking over [1], it occurs to me that treating "res_state" as an opaque type doesn't work if this API is to be actually usable.  A typical program will look like this:

       struct __res_state res;

       if (res_ninit(&res))
               die_errno("cannot initialize resolver");
       ...

Is "struct __res_state" really supposed to be part of the public API?  I guess it is.

So I'd suggest squashing in the mini-patch below to reflect that. Sorry for the noise.

[1] https://lists.isc.org/pipermail/bind-users/2008-July/070847.html

---
 man3/resolver_r.3 |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
man3/resolver_r.3 +0 -0
index f2ced438..a70834b4 100644
@@ -13,7 +13,8 @@ res_nsend \- reentrant resolver routines

 .nf
 .B #include <resolv.h>
 .sp
-.B typedef struct state *res_state;
+.B struct __res_state;
+.B typedef struct __res_state *res_state;
 .sp
 .BI "int res_ninit(res_state " statep ");"
 .sp
--
1.7.6

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive

Hi,

Quoted 1 line · Stefan Puiu

IIRC bind 8 (or libbind) also comes with its own manpages.

libbind does. Good find; not sure how I missed that.

Quoted 6 lines

Ages ago I
stole the info from their resolver.3 page and merged it with the page distributed with glibc (the current version is taken from there as well, IIRC). The patch got somehow lost through the cracks, I think...

Or do you see any licensing issues with doing that?

libbind's manpages are permissively (ISC) licensed and so pretty much hassle-free to reuse. Could you send a link or other pointer (e.g., message-id) to your patch?

Quoted 3 lines

OTOH, if you want to keep your approach and add another page for the reentrant functions, you might want to add a pointer in resolver.3 so people know there's another page as well :).

I snuck in a link in the SEE ALSO section. If you have ideas for where to broach the subject elsewhere (maybe in the paragraph discussing _res?), I'd be happy to take them. :)

Thanks for looking it over.
Jonathan
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hi,

On Mon, Jul 4, 2011 at 12:37 PM, Jonathan Nieder <[email protected]> wrote:
[...]

Quoted 10 lines
Quoted 6 lines

Ages ago I
stole the info from their resolver.3 page and merged it with the page distributed with glibc (the current version is taken from there as well, IIRC). The patch got somehow lost through the cracks, I think...

Or do you see any licensing issues with doing that?

libbind's manpages are permissively (ISC) licensed and so pretty much hassle-free to reuse.  Could you send a link or other pointer (e.g., message-id) to your patch?

That was before there was a linux-man mailing list; I still have Michael's replies, but apparently I don't the one I sent. I will check my home computer, maybe I have a copy of it there. I'll get back with a reply if I manage to find it.

On re-reading Michael's replies, I see there was a problem with the format of the man pages - the one from libbind is using mdoc, while the one in man-pages uses the newer man(7) format. Just a heads up.

Quoted 8 lines
Quoted 4 lines

OTOH, if you want to keep your approach and add another page for the reentrant functions, you might want to add a pointer in resolver.3 so people know there's another page as well :).

I snuck in a link in the SEE ALSO section.  If you have ideas for where to broach the subject elsewhere (maybe in the paragraph discussing _res?), I'd be happy to take them. :)

Maybe at the beginning you could say that the man page documents only the non-reentrant functions? OTOH, as far as I can make of the old email exchange, the current man page is based on what BIND 4.9.something was shipping, probably before anybody started thinking about multithreading :).

Quoted 4 lines

Thanks for looking it over.
Jonathan

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
In reply to a message not in the archive

Hi,

I believe the attached file is the page I converted from libbind docs for resolver.3; I had to spend some time looking for it. It's been 5 years, so I don't remember too many details, so please don't be too harsh :). I lifted and converted the man page from BIND 8.2.3, which was quite recent at the time (and I don't think the API changed much until 8.4.x).

Thanks,
Stefan.

Quoted 44 lines · Stefan Puiu

Hi,

On Mon, Jul 4, 2011 at 12:37 PM, Jonathan Nieder <[email protected]> wrote:
[...]

Quoted 10 lines
Quoted 6 lines

Ages ago I
stole the info from their resolver.3 page and merged it with the page distributed with glibc (the current version is taken from there as well, IIRC). The patch got somehow lost through the cracks, I think...

Or do you see any licensing issues with doing that?

libbind's manpages are permissively (ISC) licensed and so pretty much hassle-free to reuse.  Could you send a link or other pointer (e.g., message-id) to your patch?

That was before there was a linux-man mailing list; I still have Michael's replies, but apparently I don't the one I sent. I will check my home computer, maybe I have a copy of it there. I'll get back with a reply if I manage to find it.

On re-reading Michael's replies, I see there was a problem with the format of the man pages - the one from libbind is using mdoc, while the one in man-pages uses the newer man(7) format. Just a heads up.

Quoted 8 lines
Quoted 4 lines

OTOH, if you want to keep your approach and add another page for the reentrant functions, you might want to add a pointer in resolver.3 so people know there's another page as well :).

I snuck in a link in the SEE ALSO section.  If you have ideas for where to broach the subject elsewhere (maybe in the paragraph discussing _res?), I'd be happy to take them. :)

Maybe at the beginning you could say that the man page documents only the non-reentrant functions? OTOH, as far as I can make of the old email exchange, the current man page is based on what BIND 4.9.something was shipping, probably before anybody started thinking about multithreading :).

Quoted 4 lines

Thanks for looking it over.
Jonathan