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/libunixonacid | |
parent | 465ac8d55b18b05a5065d2cb9ecd40e18542b555 (diff) | |
download | skalibs-2dc97e2b5c06f8fafcefe413592de3251a57d923.tar.xz |
Add skaclient_syncify for easier async/sync handling
Diffstat (limited to 'src/libunixonacid')
-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 |
3 files changed, 7 insertions, 15 deletions
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) ; } |