diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-03-01 08:51:50 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-03-01 08:51:50 +0000 |
| commit | 9c781a2be58c60101aa96a9606117693204cc1a4 (patch) | |
| tree | 6738cfa96b6f015444246f016920df6581f37477 /src/libunixonacid/buffer_timed_putv.c | |
| parent | b6e920192eee90fa2d403a6616129149c8daba97 (diff) | |
| download | skalibs-9c781a2be58c60101aa96a9606117693204cc1a4.tar.gz | |
Add timed_read[v], buffer_timed_[get|put]v
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libunixonacid/buffer_timed_putv.c')
| -rw-r--r-- | src/libunixonacid/buffer_timed_putv.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libunixonacid/buffer_timed_putv.c b/src/libunixonacid/buffer_timed_putv.c new file mode 100644 index 0000000..0dfd56a --- /dev/null +++ b/src/libunixonacid/buffer_timed_putv.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include <sys/uio.h> + +#include <skalibs/buffer.h> +#include <skalibs/siovec.h> +#include <skalibs/unix-timed.h> + +size_t buffer_timed_putv (buffer *b, struct iovec const *v, unsigned int vlen, tain const *deadline, tain *stamp) +{ + if (!vlen) return 0 ; + size_t tot = siovec_len(v, vlen), w = 0 ; + struct iovec vv[vlen] ; + for (unsigned int i = 0 ; i < vlen ; i++) vv[i] = v[i] ; + while (w < tot) + { + size_t r = buffer_putvnoflush(b, vv, vlen) ; + w += r ; siovec_seek(vv, vlen, r) ; + if (!buffer_timed_flush(b, deadline, stamp)) break ; + } + return w ; +} |
