summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client/rsync.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-10-23 16:06:05 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-10-23 16:06:05 +0000
commitbb77e8c7230b8d87fd5c3f08ab8aceb8cb945b9b (patch)
tree98a07e9f5a55cf10afbde8f82a72dfe8221cba0c /usr.sbin/rpki-client/rsync.c
parentc99b36cfd4f2cd5e603a9e0b535c422e5368701e (diff)
Finnally move away from blocking reads in rpki-client. The code was a
mish mash of poll, non-blocking writes and blocking reads. Using the introduced ibuf size header in io_buf_new()/io_buf_close() the read side can be changed to pull in a full ibuf and only start the un-marshal once all data has been read. OK benno@
Diffstat (limited to 'usr.sbin/rpki-client/rsync.c')
-rw-r--r--usr.sbin/rpki-client/rsync.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c
index 6b115447cdb..839250b03e7 100644
--- a/usr.sbin/rpki-client/rsync.c
+++ b/usr.sbin/rpki-client/rsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsync.c,v 1.26 2021/10/22 11:13:06 claudio Exp $ */
+/* $OpenBSD: rsync.c,v 1.27 2021/10/23 16:06:04 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -120,6 +120,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
int rc = 0;
struct pollfd pfd;
struct msgbuf msgq;
+ struct ibuf *b, *inbuf = NULL;
sigset_t mask, oldmask;
struct rsyncproc *ids = NULL;
@@ -178,7 +179,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
for (;;) {
char *uri = NULL, *dst = NULL;
- size_t id, size;
+ size_t id;
pid_t pid;
int st;
@@ -198,7 +199,6 @@ proc_rsync(char *prog, char *bind_addr, int fd)
*/
while ((pid = waitpid(WAIT_ANY, &st, WNOHANG)) > 0) {
- struct ibuf *b;
int ok = 1;
for (i = 0; i < idsz; i++)
@@ -247,11 +247,17 @@ proc_rsync(char *prog, char *bind_addr, int fd)
if (!(pfd.revents & POLLIN))
continue;
+ b = io_buf_read(fd, &inbuf);
+ if (b == NULL)
+ continue;
+
/* Read host and module. */
- io_simple_read(fd, &size, sizeof(size));
- io_simple_read(fd, &id, sizeof(id));
- io_str_read(fd, &dst);
- io_str_read(fd, &uri);
+ io_read_buf(b, &id, sizeof(id));
+ io_read_str(b, &dst);
+ io_read_str(b, &uri);
+
+ ibuf_free(b);
+
assert(dst);
assert(uri);