diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-04 19:00:46 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-04 19:00:46 +0000 |
commit | 5b4cf1798bfaf7be1dfaea36614757db80cae23d (patch) | |
tree | 3ab634ccb9bfe4de6c50be8c0f1cef48d2d53914 /src | |
parent | d76cbe1a8d6ae1e839bd7613f3291da2c9b042d0 (diff) | |
download | skalibs-5b4cf1798bfaf7be1dfaea36614757db80cae23d.tar.xz |
Add unixmessage_drop and some stuff in skaclient
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/skaclient.h | 2 | ||||
-rw-r--r-- | src/include/skalibs/unixmessage.h | 2 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_drop.c | 13 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h index 4705df1..2875304 100644 --- a/src/include/skalibs/skaclient.h +++ b/src/include/skalibs/skaclient.h @@ -99,6 +99,7 @@ extern int skaclient_sendv (skaclient_t *, siovec_t const *, unsigned int, unixm #define skaclient_sendv_g(a, v, vlen, cb, result, deadline) skaclient_sendv(a, v, vlen, cb, result, (deadline), &STAMP) #define skaclient_sfd(a) unixmessage_receiver_fd(&(a)->syncin) +#define skaclient_siswritable(a) (!unixmessage_sender_isempty(&(a)->syncout)) #define skaclient_flush(a) unixmessage_sender_flush(&(a)->syncout) #define skaclient_timed_flush(a, deadline, stamp) unixmessage_sender_timed_flush(&(a)->syncout, deadline, stamp) #define skaclient_timed_flush_g(a, deadline) skaclient_timed_flush(a, (deadline), &STAMP) @@ -116,6 +117,7 @@ extern int skaclient_syncify (skaclient_t *, tain_t const *, tain_t *) ; extern unixmessage_handler_func_t skaclient_default_cb ; +#define skaclient_aiswritable(a) (!unixmessage_sender_isempty(&(a)->asyncout)) #define skaclient_aput_and_close(a, m, bits) unixmessage_put_and_close(&(a)->asyncout, m, bits) #define skaclient_aputv_and_close(a, m, bits) unixmessage_putv_and_close(&(a)->asyncout, m, bits) #define skaclient_aput(a, m) unixmessage_put(&(a)->asyncout, m) diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h index e45dc09..eaf66c5 100644 --- a/src/include/skalibs/unixmessage.h +++ b/src/include/skalibs/unixmessage.h @@ -26,6 +26,8 @@ struct unixmessage_s #define UNIXMESSAGE_ZERO { .s = 0, .len = 0, .fds = 0, .nfds = 0 } extern unixmessage_t const unixmessage_zero ; +extern void unixmessage_drop (unixmessage_t const *) ; + typedef struct unixmessage_v_s unixmessage_v_t, *unixmessage_v_t_ref ; struct unixmessage_v_s { diff --git a/src/libunixonacid/unixmessage_drop.c b/src/libunixonacid/unixmessage_drop.c new file mode 100644 index 0000000..7fa34fb --- /dev/null +++ b/src/libunixonacid/unixmessage_drop.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +#include <errno.h> +#include <skalibs/djbunix.h> +#include <skalibs/unixmessage.h> + +void unixmessage_drop (unixmessage_t const *m) +{ + int e = errno ; + register unsigned int i = 0 ; + for (; i < m->nfds ; i++) fd_close(m->fds[i]) ; + errno = e ; +} |