From 885cd198c0be874147a0e98e106a85abf720a7f1 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 20 Jul 2016 19:20:08 +0000 Subject: Add ipc_timed_recv --- src/include/skalibs/unix-timed.h | 2 ++ src/libunixonacid/buffer_timed_get.c | 1 + src/libunixonacid/ipc_timed_recv.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/libunixonacid/ipc_timed_recv.c (limited to 'src') diff --git a/src/include/skalibs/unix-timed.h b/src/include/skalibs/unix-timed.h index c3ae4cd..68c6361 100644 --- a/src/include/skalibs/unix-timed.h +++ b/src/include/skalibs/unix-timed.h @@ -35,5 +35,7 @@ extern int netstring_timed_get (buffer *, stralloc *, tain_t const *, tain_t *) extern int ipc_timed_send (int, char const *, unsigned int, tain_t const *, tain_t *) ; #define ipc_timed_send_g(fd, s, len, deadline) ipc_timed_send(fd, s, len, (deadline), &STAMP) +extern int ipc_timed_get (int, char *, unsigned int, char *, tain_t const *, tain_t *) ; +#define ipc_timed_get_g(fd, s, len, path, deadline) ipc_timed_get(fd, s, len, path, (deadline), &STAMP) #endif diff --git a/src/libunixonacid/buffer_timed_get.c b/src/libunixonacid/buffer_timed_get.c index 2f3b751..af846ff 100644 --- a/src/libunixonacid/buffer_timed_get.c +++ b/src/libunixonacid/buffer_timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include diff --git a/src/libunixonacid/ipc_timed_recv.c b/src/libunixonacid/ipc_timed_recv.c new file mode 100644 index 0000000..bcb991d --- /dev/null +++ b/src/libunixonacid/ipc_timed_recv.c @@ -0,0 +1,30 @@ +/* ISC license. */ + +#include +#include +#include +#include + +struct blah_s +{ + int fd ; + char *s ; + unsigned int len ; + char *path ; +} ; + +static int getfd (struct blah_s *blah) +{ + return blah->fd ; +} + +static int get (struct blah_s *blah) +{ + return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ; +} + +int ipc_timed_get (int fd, char *s, unsigned int len, char *path, tain_t const *deadline, tain_t *stamp) +{ + struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; +} -- cgit v1.2.3