summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-12-22 16:07:12 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-12-22 16:07:12 +0000
commit275183baefa08dc91f094c1e59bd43a77684662d (patch)
tree2aeeb04d0c650afd05ad42de8f4f1f708527aa2e
parent6f2f670455a24032face2d8ee4684d051ae0e907 (diff)
downloads6-dns-275183baefa08dc91f094c1e59bd43a77684662d.tar.xz
Port skadns to textclient, prepare for 2.3.0.0
-rw-r--r--INSTALL2
-rw-r--r--NEWS7
-rw-r--r--doc/index.html4
-rw-r--r--doc/upgrade.html8
-rw-r--r--package/info2
-rw-r--r--src/include/s6-dns/skadns.h9
-rw-r--r--src/skadns/skadns_cancel.c11
-rw-r--r--src/skadns/skadns_end.c4
-rw-r--r--src/skadns/skadns_send.c12
-rw-r--r--src/skadns/skadns_start.c4
-rw-r--r--src/skadns/skadns_startf.c6
-rw-r--r--src/skadns/skadns_update.c23
-rw-r--r--src/skadns/skadnsd.c52
13 files changed, 76 insertions, 68 deletions
diff --git a/INSTALL b/INSTALL
index b008974..f6274cd 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,7 +6,7 @@ Build Instructions
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- - skalibs version 2.6.0.0 or later: http://skarnet.org/software/skalibs/
+ - skalibs version 2.6.3.0 or later: http://skarnet.org/software/skalibs/
This software will run on any operating system that implements
POSIX.1-2008, available at:
diff --git a/NEWS b/NEWS
index 8587bc8..b779c1a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,12 @@
Changelog for s6-dns.
+In 2.3.0.0
+----------
+
+ - skadns now uses the textclient API/ABI instead of the skaclient one.
+The change is invisible, but it's leaner and faster.
+
+
In 2.2.0.1
----------
diff --git a/doc/index.html b/doc/index.html
index c83eac1..67ccdc8 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -46,7 +46,7 @@ point in the future.
<li> A POSIX-compliant system with a standard C development environment </li>
<li> GNU make, version 3.81 or later </li>
<li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version
-2.6.0.0 or later </li>
+2.6.3.0 or later </li>
</ul>
<h3> Licensing </h3>
@@ -59,7 +59,7 @@ point in the future.
<h3> Download </h3>
<ul>
- <li> The current released version of s6-dns is <a href="s6-dns-2.2.0.1.tar.gz">2.2.0.1</a>. </li>
+ <li> The current released version of s6-dns is <a href="s6-dns-2.3.0.0.tar.gz">2.3.0.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6-dns/">s6-dns
git repository</a>:
diff --git a/doc/upgrade.html b/doc/upgrade.html
index f74654d..a0e5b64 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -18,6 +18,14 @@
<h1> What has changed in s6-dns </h1>
+<h2> in 2.3.0.0 </h2>
+
+<ul>
+ <li> skalibs dependency bumped to 2.6.0.0. </li>
+ <li> skadns now uses the textclient API/ABI instead of the skaclient one.
+The change should not be externally visible. </li>
+</ul>
+
<h2> in 2.2.0.1 </h2>
<ul>
diff --git a/package/info b/package/info
index ce41d09..bcc8aaf 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=s6-dns
-version=2.2.0.1
+version=2.3.0.0
category=web
package_macro_name=S6_DNS
diff --git a/src/include/s6-dns/skadns.h b/src/include/s6-dns/skadns.h
index b2a5aff..d45e327 100644
--- a/src/include/s6-dns/skadns.h
+++ b/src/include/s6-dns/skadns.h
@@ -8,7 +8,7 @@
#include <skalibs/tai.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/config.h>
#include <s6-dns/s6dns-domain.h>
@@ -31,12 +31,11 @@ struct skadnsanswer_s
typedef struct skadns_s skadns_t, *skadns_t_ref ;
struct skadns_s
{
- skaclient_t connection ;
+ textclient_t connection ;
genalloc list ; /* array of uint16_t */
gensetdyn q ; /* set of skadnsanswer_t */
- skaclient_buffer_t buffers ;
} ;
-#define SKADNS_ZERO { .connection = SKACLIENT_ZERO, .list = GENALLOC_ZERO, .q = GENSETDYN_INIT(skadnsanswer_t, 3, 3, 8) }
+#define SKADNS_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .q = GENSETDYN_INIT(skadnsanswer_t, 3, 3, 8) }
extern skadns_t const skadns_zero ;
@@ -59,7 +58,7 @@ extern int skadns_cancel (skadns_t *, uint16_t, tain_t const *, tain_t *) ;
/* Asynchronous functions */
-#define skadns_fd(a) skaclient_fd(&(a)->connection)
+#define skadns_fd(a) textclient_fd(&(a)->connection)
extern int skadns_update (skadns_t *) ;
#define skadns_list(a) genalloc_s(uint16_t const, &(a)->list)
#define skadns_clearlist(a) ((a)->list.len = 0)
diff --git a/src/skadns/skadns_cancel.c b/src/skadns/skadns_cancel.c
index 8a4ec7c..c5062f6 100644
--- a/src/skadns/skadns_cancel.c
+++ b/src/skadns/skadns_cancel.c
@@ -9,19 +9,20 @@
#include <skalibs/uint16.h>
#include <skalibs/error.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
int skadns_cancel (skadns_t *a, uint16_t id, tain_t const *deadline, tain_t *stamp)
{
+ int e = errno ;
char pack[3] = "--q" ;
- char err ;
skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ;
if (!error_isagain(p->status)) return skadns_release(a, id) ;
uint16_pack_big(pack, id) ;
- if (!skaclient_send(&a->connection, pack, 3, &skaclient_default_cb, &err, deadline, stamp)) return 0 ;
- if (!err) return gensetdyn_delete(&a->q, id) ;
- if (err != ENOENT) return (errno = err, 0) ;
+ if (textclient_command(&a->connection, pack, 3, deadline, stamp))
+ return gensetdyn_delete(&a->q, id) ;
+ if (errno != ENOENT) return 0 ;
p->status = ECANCELED ;
+ errno = e ;
return 1 ;
}
diff --git a/src/skadns/skadns_end.c b/src/skadns/skadns_end.c
index 252e959..60ae9c9 100644
--- a/src/skadns/skadns_end.c
+++ b/src/skadns/skadns_end.c
@@ -4,7 +4,7 @@
#include <skalibs/alloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
static int skadnsanswer_free (char *p, void *stuff)
@@ -17,7 +17,7 @@ static int skadnsanswer_free (char *p, void *stuff)
void skadns_end (skadns_t *a)
{
- skaclient_end(&a->connection) ;
+ textclient_end(&a->connection) ;
genalloc_free(uint16_t, &a->list) ;
gensetdyn_iter(&a->q, &skadnsanswer_free, 0) ;
gensetdyn_free(&a->q) ;
diff --git a/src/skadns/skadns_send.c b/src/skadns/skadns_send.c
index 9df39f0..69f533f 100644
--- a/src/skadns/skadns_send.c
+++ b/src/skadns/skadns_send.c
@@ -6,16 +6,15 @@
#include <errno.h>
#include <skalibs/uint16.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
-static skadnsanswer_t const skadnsanswer_initial = { .status = EAGAIN, .data = 0, .len = 0 } ;
int skadns_send (skadns_t *a, uint16_t *u, s6dns_domain_t const *d, uint16_t qtype, tain_t const *limit, tain_t const *deadline, tain_t *stamp)
{
+ static skadnsanswer_t const skadnsanswer_initial = { .status = EAGAIN, .data = 0, .len = 0 } ;
uint32_t i ;
char tmp[17] = "--Q" ;
- char err ;
struct iovec v[2] = { { .iov_base = tmp, .iov_len = 17 }, { .iov_base = (void *)d->s, .iov_len = d->len } } ;
if (!gensetdyn_new(&a->q, &i)) return 0 ;
if (i > UINT16_MAX)
@@ -26,18 +25,13 @@ int skadns_send (skadns_t *a, uint16_t *u, s6dns_domain_t const *d, uint16_t qty
uint16_pack_big(tmp, (uint16_t)i) ;
uint16_pack_big(tmp + 3, qtype) ;
if (limit) tain_pack(tmp + 5, limit) ; else memset(tmp + 5, 0, 12) ;
- if (!skaclient_sendv(&a->connection, v, 2, &skaclient_default_cb, &err, deadline, stamp))
+ if (!textclient_commandv(&a->connection, v, 2, deadline, stamp))
{
int e = errno ;
gensetdyn_delete(&a->q, i) ;
errno = e ;
return 0 ;
}
- if (err)
- {
- gensetdyn_delete(&a->q, i) ;
- return (errno = err, 0) ;
- }
*GENSETDYN_P(skadnsanswer_t, &a->q, i) = skadnsanswer_initial ;
*u = i ;
return 1 ;
diff --git a/src/skadns/skadns_start.c b/src/skadns/skadns_start.c
index f2376e2..dbb7f63 100644
--- a/src/skadns/skadns_start.c
+++ b/src/skadns/skadns_start.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
int skadns_start (skadns_t *a, char const *path, tain_t const *deadline, tain_t *stamp)
{
- return skaclient_start_b(&a->connection, &a->buffers, path, 0, SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, deadline, stamp) ;
+ return textclient_start(&a->connection, path, 0, SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, deadline, stamp) ;
}
diff --git a/src/skadns/skadns_startf.c b/src/skadns/skadns_startf.c
index 8dc1675..29c44bf 100644
--- a/src/skadns/skadns_startf.c
+++ b/src/skadns/skadns_startf.c
@@ -1,11 +1,11 @@
/* ISC license. */
-#include <skalibs/environ.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/posixplz.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
int skadns_startf (skadns_t *a, tain_t const *deadline, tain_t *stamp)
{
static char const *const cargv[2] = { SKADNSD_PROG, 0 } ;
- return skaclient_startf_b(&a->connection, &a->buffers, cargv[0], cargv, (char const *const *)environ, SKACLIENT_OPTION_WAITPID, SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, deadline, stamp) ;
+ return textclient_startf(&a->connection, cargv, (char const *const *)environ, TEXTCLIENT_OPTION_WAITPID, SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, deadline, stamp) ;
}
diff --git a/src/skadns/skadns_update.c b/src/skadns/skadns_update.c
index 39b1dd0..e26ead0 100644
--- a/src/skadns/skadns_update.c
+++ b/src/skadns/skadns_update.c
@@ -5,6 +5,7 @@
#define _BSD_SOURCE
#endif
+#include <sys/uio.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
@@ -13,17 +14,17 @@
#include <skalibs/alloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-#include <skalibs/unixmessage.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textclient.h>
#include <s6-dns/skadns.h>
-static int msghandler (unixmessage_t const *m, void *context)
+static int msghandler (struct iovec const *v, void *context)
{
skadns_t *a = (skadns_t *)context ;
+ char const *s = v->iov_base ;
skadnsanswer_t *p ;
uint16_t id ;
- if (m->len < 3 || m->nfds) return (errno = EPROTO, 0) ;
- uint16_unpack_big(m->s, &id) ;
+ if (v->iov_len < 3) return (errno = EPROTO, 0) ;
+ uint16_unpack_big(s, &id) ;
p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ;
if (p->status == ECANCELED)
{
@@ -32,14 +33,14 @@ static int msghandler (unixmessage_t const *m, void *context)
}
if (!error_isagain(p->status)) return (errno = EINVAL, 0) ;
if (!genalloc_readyplus(uint16_t, &a->list, 1)) return 0 ;
- if (!m->s[2])
+ if (!s[2])
{
- p->data = alloc(m->len-3) ;
+ p->data = alloc(v->iov_len-3) ;
if (!p->data) return 0 ;
- memcpy(p->data, m->s+3, m->len-3) ;
- p->len = m->len-3 ;
+ memcpy(p->data, s+3, v->iov_len-3) ;
+ p->len = v->iov_len-3 ;
}
- p->status = m->s[2] ;
+ p->status = s[2] ;
genalloc_append(uint16_t, &a->list, &id) ;
return 1 ;
}
@@ -47,5 +48,5 @@ static int msghandler (unixmessage_t const *m, void *context)
int skadns_update (skadns_t *a)
{
genalloc_setlen(uint16_t, &a->list, 0) ;
- return skaclient_update(&a->connection, &msghandler, a) ;
+ return textclient_update(&a->connection, &msghandler, a) ;
}
diff --git a/src/skadns/skadnsd.c b/src/skadns/skadnsd.c
index b1b0687..9f6a945 100644
--- a/src/skadns/skadnsd.c
+++ b/src/skadns/skadnsd.c
@@ -12,8 +12,8 @@
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
#include <skalibs/iopause.h>
-#include <skalibs/unixmessage.h>
-#include <skalibs/skaclient.h>
+#include <skalibs/textmessage.h>
+#include <skalibs/textclient.h>
#include <s6-dns/s6dns.h>
#include <s6-dns/skadns.h>
@@ -40,44 +40,43 @@ static void remove (unsigned int i)
static void fail (unsigned int i)
{
char pack[3] ;
- unixmessage_t m = { .s = pack, .len = 3, .fds = 0, .nfds = 0 } ;
uint16_pack_big(pack, a[i].id) ;
pack[2] = a[i].dt.status ;
s6dns_engine_recycle(&a[i].dt) ;
remove(i) ;
- if (!unixmessage_put(unixmessage_sender_x, &m))
- strerr_diefu1sys(111, "unixmessage_put") ;
+ if (!textmessage_put(textmessage_sender_x, pack, 3))
+ strerr_diefu1sys(111, "textmessage_put") ;
}
static void answer (char c)
{
- unixmessage_t m = { .s = &c, .len = 1, .fds = 0, .nfds = 0 } ;
- if (!unixmessage_put(unixmessage_sender_1, &m))
+ if (!textmessage_put(textmessage_sender_1, &c, 1))
strerr_diefu1sys(111, "unixmessage_put") ;
}
-static int parse_protocol (unixmessage_t const *m, void *context)
+static int parse_protocol (struct iovec const *v, void *context)
{
+ char const *s = v->iov_base ;
uint16_t id ;
- if (m->len < 3 || m->nfds) strerr_dief1x(100, "invalid client request") ;
- uint16_unpack_big(m->s, &id) ;
- switch (m->s[2]) /* protocol parsing */
+ if (v->iov_len < 3) strerr_dief1x(100, "invalid client request") ;
+ uint16_unpack_big(s, &id) ;
+ switch (s[2]) /* protocol parsing */
{
case 'Q' : /* send a query */
{
tain_t limit ;
uint16_t qtype ;
- if (m->len < 21) strerr_dief1x(100, "invalid client request") ;
+ if (v->iov_len < 21) strerr_dief1x(100, "invalid client request") ;
if (sp >= SKADNS_MAXCONCURRENCY)
{
answer(ENFILE) ;
break ;
}
- uint16_unpack_big(m->s + 3, &qtype) ;
- if (memcmp(m->s + 5, "\0\0\0\0\0\0\0\0\0\0\0", 12))
- tain_unpack(m->s + 5, &limit) ;
+ uint16_unpack_big(s + 3, &qtype) ;
+ if (memcmp(s + 5, "\0\0\0\0\0\0\0\0\0\0\0", 12))
+ tain_unpack(s + 5, &limit) ;
else tain_add_g(&limit, &tain_infinite_relative) ;
- if (!s6dns_engine_init_g(&a[sp].dt, &s6dns_rci_here.servers, 1, m->s + 17, m->len - 17, qtype, &limit))
+ if (!s6dns_engine_init_g(&a[sp].dt, &s6dns_rci_here.servers, 1, s + 17, v->iov_len - 17, qtype, &limit))
{
answer(errno) ;
break ;
@@ -119,7 +118,7 @@ int main (void)
{
tain_t deadline ;
tain_addsec_g(&deadline, 2) ;
- if (!skaclient_server_01x_init_g(SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, &deadline))
+ if (!textclient_server_01x_init_g(SKADNS_BANNER1, SKADNS_BANNER1_LEN, SKADNS_BANNER2, SKADNS_BANNER2_LEN, &deadline))
strerr_diefu1sys(111, "sync with client") ;
}
{
@@ -134,9 +133,9 @@ int main (void)
int r ;
x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ;
- x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (unixmessage_sender_isempty(unixmessage_sender_1) ? 0 : IOPAUSE_WRITE) ;
- x[2].fd = unixmessage_sender_fd(unixmessage_sender_x) ;
- x[2].events = IOPAUSE_EXCEPT | (unixmessage_sender_isempty(unixmessage_sender_x) ? 0 : IOPAUSE_WRITE) ;
+ x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_1) ? 0 : IOPAUSE_WRITE) ;
+ x[2].fd = textmessage_sender_fd(textmessage_sender_x) ;
+ x[2].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_x) ? 0 : IOPAUSE_WRITE) ;
{
tain_t deadline = TAIN_INFINITE ;
unsigned int i = 0 ;
@@ -162,10 +161,10 @@ int main (void)
}
if (x[1].revents & IOPAUSE_WRITE)
- if (!unixmessage_sender_flush(unixmessage_sender_1) && !error_isagain(errno))
+ if (!textmessage_sender_flush(textmessage_sender_1) && !error_isagain(errno))
strerr_diefu1sys(111, "flush stdout") ;
if (x[2].revents & IOPAUSE_WRITE)
- if (!unixmessage_sender_flush(unixmessage_sender_x) && !error_isagain(errno))
+ if (!textmessage_sender_flush(textmessage_sender_x) && !error_isagain(errno))
strerr_diefu1sys(111, "flush asyncout") ;
{
@@ -178,20 +177,19 @@ int main (void)
{
char pack[3] ;
struct iovec v[2] = { { .iov_base = pack, .iov_len = 3 }, { .iov_base = s6dns_engine_packet(&a[i].dt), .iov_len = s6dns_engine_packetlen(&a[i].dt) } } ;
- unixmessage_v_t mv = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ;
uint16_pack_big(pack, a[i].id) ;
pack[2] = 0 ;
- if (!unixmessage_putv(unixmessage_sender_x, &mv))
- strerr_diefu1sys(111, "unixmessage_put") ;
+ if (!textmessage_putv(textmessage_sender_x, v, 2))
+ strerr_diefu1sys(111, "textmessage_put") ;
s6dns_engine_recycle(&a[i].dt) ;
remove(i--) ;
}
}
}
- if (!unixmessage_receiver_isempty(unixmessage_receiver_0) || x[0].revents & IOPAUSE_READ)
+ if (!textmessage_receiver_isempty(textmessage_receiver_0) || x[0].revents & IOPAUSE_READ)
{
- if (unixmessage_handle(unixmessage_receiver_0, &parse_protocol, 0) < 0)
+ if (textmessage_handle(textmessage_receiver_0, &parse_protocol, 0) < 0)
{
if (errno == EPIPE) break ; /* normal exit */
strerr_diefu1sys(111, "handle messages from client") ;