skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 2dc97e2b5c06f8fafcefe413592de3251a57d923
parent 465ac8d55b18b05a5065d2cb9ecd40e18542b555
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri,  2 Jan 2015 15:28:30 +0000

 Add skaclient_syncify for easier async/sync handling

Diffstat:
Mpackage/deps.mak | 1+
Msrc/include/skalibs/skaclient.h | 2++
Msrc/libunixonacid/skaclient_send.c | 2+-
Msrc/libunixonacid/skaclient_sendmsg.c | 10+++-------
Msrc/libunixonacid/skaclient_sendmsgv.c | 10+++-------
5 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/package/deps.mak b/package/deps.mak @@ -734,6 +734,7 @@ src/libunixonacid/skaclient_start_async.o src/libunixonacid/skaclient_start_asyn src/libunixonacid/skaclient_start_cb.o src/libunixonacid/skaclient_start_cb.lo: src/libunixonacid/skaclient_start_cb.c src/include/skalibs/bytestr.h src/include/skalibs/error.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h src/libunixonacid/skaclient_startf.o src/libunixonacid/skaclient_startf.lo: src/libunixonacid/skaclient_startf.c src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/libunixonacid/skaclient_startf_async.o src/libunixonacid/skaclient_startf_async.lo: src/libunixonacid/skaclient_startf_async.c src/include/skalibs/djbunix.h src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/uint32.h +src/libunixonacid/skaclient_syncify.o src/libunixonacid/skaclient_syncify.lo: src/libunixonacid/skaclient_syncify.c src/include/skalibs/skaclient.h src/include/skalibs/tai.h src/libunixonacid/skaclient_zero.o src/libunixonacid/skaclient_zero.lo: src/libunixonacid/skaclient_zero.c src/include/skalibs/skaclient.h src/libunixonacid/timed_flush.o src/libunixonacid/timed_flush.lo: src/libunixonacid/timed_flush.c src/include/skalibs/bufalloc.h src/include/skalibs/error.h src/include/skalibs/functypes.h src/include/skalibs/iopause.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h src/libunixonacid/timed_get.o src/libunixonacid/timed_get.lo: src/libunixonacid/timed_get.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/include/skalibs/iopause.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h @@ -107,6 +107,8 @@ extern int skaclient_sendv (skaclient_t *, siovec_t const *, unsigned int, unixm #define skaclient_timed_supdate(a, deadline, stamp) unixmessage_timed_handle(&(a)->syncin, (unixmessage_handler_func_t *)&kolbak_call, &(a)->kq, deadline, stamp) #define skaclient_timed_supdate_g(a, deadline) skaclient_timed_supdate(a, (deadline), &STAMP) +extern int skaclient_syncify (skaclient_t *, tain_t const *, tain_t *) ; + #define skaclient_fd(a) skaclient_afd(a) #define skaclient_afd(a) unixmessage_receiver_fd(&(a)->asyncin) #define skaclient_update(a, f, p) skaclient_aupdate(a, f, p) diff --git a/src/libunixonacid/skaclient_send.c b/src/libunixonacid/skaclient_send.c @@ -1,8 +1,8 @@ /* ISC license. */ -#include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> +#include <skalibs/skaclient.h> int skaclient_send (skaclient_t *a, char const *s, unsigned int len, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { diff --git a/src/libunixonacid/skaclient_sendmsg.c b/src/libunixonacid/skaclient_sendmsg.c @@ -1,15 +1,11 @@ /* ISC license. */ -#include <errno.h> -#include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> +#include <skalibs/skaclient.h> int skaclient_sendmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { - register int r ; - if (!skaclient_putmsg_and_close(a, m, bits, cb, result)) return 0 ; - if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; - r = skaclient_timed_supdate(a, deadline, stamp) ; - return r < 0 ? 0 : !r ? (errno = EPIPE, 0) : 1 ; + return skaclient_putmsg_and_close(a, m, bits, cb, result) + && skaclient_syncify(a, deadline, stamp) ; } diff --git a/src/libunixonacid/skaclient_sendmsgv.c b/src/libunixonacid/skaclient_sendmsgv.c @@ -1,15 +1,11 @@ /* ISC license. */ -#include <errno.h> -#include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> +#include <skalibs/skaclient.h> int skaclient_sendmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { - register int r ; - if (!skaclient_putmsgv_and_close(a, m, bits, cb, result)) return 0 ; - if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; - r = skaclient_timed_supdate(a, deadline, stamp) ; - return r < 0 ? 0 : !r ? (errno = EPIPE, 0) : 1 ; + return skaclient_putmsgv_and_close(a, m, bits, cb, result) + && skaclient_syncify(a, deadline, stamp) ; }