summaryrefslogtreecommitdiff
path: root/lib/ringbuf.h
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2021-03-05 18:14:11 -0300
committerRafael Zalamena <rzalamena@opensourcerouting.org>2021-03-05 18:17:27 -0300
commitd9d7af1a52d77ed0074ebb72f87678308296e74e (patch)
treee5663c17ea0780bbf043527e31a374de1f163a65 /lib/ringbuf.h
parent130daf24ae1acf5db602e55c13b9ffca139a1dbf (diff)
lib: add ringbuf socket read function
Implement new ringbuf function to do the proper socket reads without the need of intermediary buffers. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'lib/ringbuf.h')
-rw-r--r--lib/ringbuf.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ringbuf.h b/lib/ringbuf.h
index b8f4d9798d..209687512b 100644
--- a/lib/ringbuf.h
+++ b/lib/ringbuf.h
@@ -126,6 +126,17 @@ void ringbuf_reset(struct ringbuf *buf);
*/
void ringbuf_wipe(struct ringbuf *buf);
+/**
+ * Perform a socket/file `read()` in to the ring buffer.
+ *
+ * \param buf the ring buffer pointer.
+ * \param sock the file descriptor.
+ * \returns the number of bytes read, `0` on connection close or `-1` with
+ * `errno` pointing the error (see `readv()` man page for more
+ * information.)
+ */
+ssize_t ringbuf_read(struct ringbuf *buf, int sock);
+
#ifdef __cplusplus
}
#endif