From 47a6797e30861e0b59f6badcfb5ef7a1a020befa Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 9 Aug 2006 11:16:59 +0000 Subject: [PATCH] + Improvements for multithreaded programs: @@ -1,3 +1,14 @@ +adns (1.3.0.99.1); urgency=low + + Improvements for multithreaded programs: + * New documentation comment in adns.h explaining thread guarantees + (or lack of them), replaces `single-threaded' note at the top. + * Fix string conversion of adns_r_addr not to use a static buffer + (function csp_addr) so as to make thread promise true. + * Make an internal variable const-correct (expectdomain in pa_ptr). + + -- + adns (1.3); urgency=low Portability fixes: --- changelog | 11 +++++++++++ src/adns.h | 14 +++++++++++++- src/types.c | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index 693120e..751f0ed 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,14 @@ +adns (1.3.0.99.1); urgency=low + + Improvements for multithreaded programs: + * New documentation comment in adns.h explaining thread guarantees + (or lack of them), replaces `single-threaded' note at the top. + * Fix string conversion of adns_r_addr not to use a static buffer + (function csp_addr) so as to make thread promise true. + * Make an internal variable const-correct (expectdomain in pa_ptr). + + -- + adns (1.3); urgency=low Portability fixes: diff --git a/src/adns.h b/src/adns.h index befa0b3..a903934 100644 --- a/src/adns.h +++ b/src/adns.h @@ -1,6 +1,6 @@ /* * adns.h - * - adns user-visible API (single-threaded, without any locking) + * - adns user-visible API */ /* * @@ -401,6 +401,18 @@ typedef struct { * requested. */ +/* Threads: + * adns does not use any static modifiable state, so it + * is safe to call adns_init several times and then use the + * resulting adns_states concurrently. + * However, it is NOT safe to make simultaneous calls into + * adns using the same adns_state; a single adns_state must be used + * only by one thread at a time. You can solve this problem by + * having one adns_state per thread, or if that isn't feasible, you + * could maintain a pool of adns_states. Unfortunately neither of + * these approaches has optimal performance. + */ + int adns_init(adns_state *newstate_r, adns_initflags flags, FILE *diagfile /*0=>stderr*/); diff --git a/src/types.c b/src/types.c index b369322..36ff879 100644 --- a/src/types.c +++ b/src/types.c @@ -320,7 +320,7 @@ static int div_addr(void *context, const void *datap_a, const void *datap_b) { static adns_status csp_addr(vbuf *vb, const adns_rr_addr *rrp) { const char *ia; - static char buf[30]; + char buf[30]; switch (rrp->addr.inet.sin_family) { case AF_INET: @@ -736,7 +736,7 @@ static void icb_ptr(adns_query parent, adns_query child) { static adns_status pa_ptr(const parseinfo *pai, int dmstart, int max, void *datap) { - static const char *(expectdomain[])= { DNS_INADDR_ARPA }; + static const char *const (expectdomain[])= { DNS_INADDR_ARPA }; char **rrp= datap; adns_status st; -- 2.30.2