From 5b4cf1798bfaf7be1dfaea36614757db80cae23d Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 4 Jan 2015 19:00:46 +0000 Subject: Add unixmessage_drop and some stuff in skaclient --- package/deps.mak | 1 + src/include/skalibs/skaclient.h | 2 ++ src/include/skalibs/unixmessage.h | 2 ++ src/libunixonacid/unixmessage_drop.c | 13 +++++++++++++ 4 files changed, 18 insertions(+) create mode 100644 src/libunixonacid/unixmessage_drop.c diff --git a/package/deps.mak b/package/deps.mak index 0e737d9..9deeecf 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -742,6 +742,7 @@ src/libunixonacid/timed_getln.o src/libunixonacid/timed_getln.lo: src/libunixona src/libunixonacid/timed_getlnmax.o src/libunixonacid/timed_getlnmax.lo: src/libunixonacid/timed_getlnmax.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h src/libunixonacid/unixmessage_bits_closeall.o src/libunixonacid/unixmessage_bits_closeall.lo: src/libunixonacid/unixmessage_bits_closeall.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_bits_closenone.o src/libunixonacid/unixmessage_bits_closenone.lo: src/libunixonacid/unixmessage_bits_closenone.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h +src/libunixonacid/unixmessage_drop.o src/libunixonacid/unixmessage_drop.lo: src/libunixonacid/unixmessage_drop.c src/include/skalibs/djbunix.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_handle.o src/libunixonacid/unixmessage_handle.lo: src/libunixonacid/unixmessage_handle.c src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_put.o src/libunixonacid/unixmessage_put.lo: src/libunixonacid/unixmessage_put.c src/include/skalibs/bitarray.h src/include/skalibs/bytestr.h src/include/skalibs/diuint.h src/include/skalibs/genalloc.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/sysdeps.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_receive.o src/libunixonacid/unixmessage_receive.lo: src/libunixonacid/unixmessage_receive.c src/include/skalibs/allreadwrite.h src/include/skalibs/cbuffer.h src/include/skalibs/djbunix.h src/include/skalibs/error.h src/include/skalibs/nonposix.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/sysdeps.h src/include/skalibs/uint.h src/include/skalibs/unixmessage.h 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 +#include +#include + +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 ; +} -- cgit v1.2.3