summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-01-04 19:00:46 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-01-04 19:00:46 +0000
commit5b4cf1798bfaf7be1dfaea36614757db80cae23d (patch)
tree3ab634ccb9bfe4de6c50be8c0f1cef48d2d53914
parentd76cbe1a8d6ae1e839bd7613f3291da2c9b042d0 (diff)
downloadskalibs-5b4cf1798bfaf7be1dfaea36614757db80cae23d.tar.xz
Add unixmessage_drop and some stuff in skaclient
-rw-r--r--package/deps.mak1
-rw-r--r--src/include/skalibs/skaclient.h2
-rw-r--r--src/include/skalibs/unixmessage.h2
-rw-r--r--src/libunixonacid/unixmessage_drop.c13
4 files changed, 18 insertions, 0 deletions
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 <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 ;
+}