[PATCH 1/2] s6dns_resolve_parse: always clean up dt, prevent fd leaking
It was noted that with no servers in resolv.conf s6-dns always leaks an fd after s6dns_resolve_parse_g() usage. I wasn't able to trace it deeper, but always cleaning up in s6dns_resolve_parse() won't hurt. --- src/libs6dns/s6dns_resolve_parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs6dns/s6dns_resolve_parse.c b/src/libs6dns/s6dns_resolve_parse.c index b00804f..065e8b1 100644 --- a/src/libs6dns/s6dns_resolve_parse.c +++ b/src/libs6dns/s6dns_resolve_parse.c @@ -10,8 +10,8 @@ int s6dns_resolve_parse_r (s6dns_domain_t const *d, uint16 qtype, s6dns_message_rr_func_t_ref parsefunc, void *data, s6dns_engine_t *dt, s6dns_ip46list_t const *servers, s6dns_debughook_t const *dbh, tain_t const *deadline, tain_t *stamp) { - register int r ; - if (!s6dns_resolve_core_r(d, qtype, dt, servers, dbh, deadline, stamp)) return -1 ; + register int r = -1; + if (s6dns_resolve_core_r(d, qtype, dt, servers, dbh, deadline, stamp)) { s6dns_message_header_t h ; r = s6dns_message_parse(h, s6dns_engine_packet(dt), s6dns_engine_packetlen(dt), parsefunc, data) ; -- 2.1.4
[PATCH 2/2] s6dns-resolve.h: make it C++ compatible
Can't use 'or' in macro, C++ compiler will complain: /usr/include/s6-dns/s6dns-resolve.h:223:40: error: or may not appear in macro parameter list #define s6dns_resolven_loop_g(list, n, or, deadline) s6dns_resolven(list, n, or, (deadline), STAMP) --- src/include/s6-dns/s6dns-resolve.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/s6-dns/s6dns-resolve.h b/src/include/s6-dns/s6dns-resolve.h index e7eb629..805ea2a 100644 --- a/src/include/s6-dns/s6dns-resolve.h +++ b/src/include/s6-dns/s6dns-resolve.h @@ -220,7 +220,7 @@ extern int s6dns_resolve_mpag_r (stralloc *, genalloc *, char const *, unsigned */ extern int s6dns_resolven_loop (s6dns_engine_t_ref, unsigned int, unsigned int, tain_t const *, tain_t *) ; -#define s6dns_resolven_loop_g(list, n, or, deadline) s6dns_resolven(list, n, or, (deadline), STAMP) +#define s6dns_resolven_loop_g(list, n, zor, deadline) s6dns_resolven(list, n, zor, (deadline), STAMP) typedef struct s6dns_resolve_s s6dns_resolve_t, *s6dns_resolve_t_ref ; struct s6dns_resolve_s -- 2.1.4
Re: [PATCH 1/2] s6dns_resolve_parse: always clean up dt, prevent fd leaking
On 11/06/2015 16:06, Roman I Khimov wrote: It was noted that with no servers in resolv.conf s6-dns always leaks an fd after s6dns_resolve_parse_g() usage. I wasn't able to trace it deeper, but always cleaning up in s6dns_resolve_parse() won't hurt. Thanks for the report! However, this isn't the correct fix. I have committed the correct one in the latest git head. (s6dns_resolve_core is supposed to recycle dt itself if it fails.) I also have applied your second patch, thanks :) New release coming soon. -- Laurent