diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-02 15:28:30 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-02 15:28:30 +0000 |
commit | 2dc97e2b5c06f8fafcefe413592de3251a57d923 (patch) | |
tree | 18c84285470d6f669e52e1928f3dea9989c6606a /src | |
parent | 465ac8d55b18b05a5065d2cb9ecd40e18542b555 (diff) | |
download | skalibs-2dc97e2b5c06f8fafcefe413592de3251a57d923.tar.xz |
Add skaclient_syncify for easier async/sync handling
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/skaclient.h | 2 | ||||
-rw-r--r-- | src/libunixonacid/skaclient_send.c | 2 | ||||
-rw-r--r-- | src/libunixonacid/skaclient_sendmsg.c | 10 | ||||
-rw-r--r-- | src/libunixonacid/skaclient_sendmsgv.c | 10 |
4 files changed, 9 insertions, 15 deletions
diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h index 947c47f..cf1aa3a 100644 --- 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 index 8bd31ab..38dcddb 100644 --- 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 index 3f88ec7..49cfbea 100644 --- 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 index ac4bcdb..6584173 100644 --- 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) ; } |