diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-12-02 15:31:16 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-12-02 15:31:16 +0000 |
commit | bfbc05d71140cfe0c2c9fd9732b840e9f2144505 (patch) | |
tree | 7a6263eb1fcd3c812514cc00fbd1a4fdc5870535 /usr.sbin/rpki-client/rsync.c | |
parent | e3aaff932b8f898a3c6e6740ebbcf3f1ae46edea (diff) |
Remove the last users of io_*_write functions that call io_simple_write()
internally. This is a step in direction of more async aware io in rpki-client.
Now everything uses a buffer which is then written.
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client/rsync.c')
-rw-r--r-- | usr.sbin/rpki-client/rsync.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c index 04cd3d5e1f2..a21b8653b4e 100644 --- a/usr.sbin/rpki-client/rsync.c +++ b/usr.sbin/rpki-client/rsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsync.c,v 1.10 2020/11/24 17:54:57 job Exp $ */ +/* $OpenBSD: rsync.c,v 1.11 2020/12/02 15:31:15 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -171,10 +171,10 @@ proc_child(int signal) void proc_rsync(char *prog, char *bind_addr, int fd) { - size_t id, i, idsz = 0; + size_t id, i, idsz = 0, bsz = 0, bmax = 0; ssize_t ssz; char *host = NULL, *mod = NULL, *uri = NULL, - *dst = NULL, *path, *save, *cmd; + *dst = NULL, *path, *save, *cmd, *b = NULL; const char *pp; pid_t pid; char *args[32]; @@ -265,8 +265,13 @@ proc_rsync(char *prog, char *bind_addr, int fd) ok = 0; } - io_simple_write(fd, &ids[i].id, sizeof(size_t)); - io_simple_write(fd, &ok, sizeof(ok)); + io_simple_buffer(&b, &bsz, &bmax, + &ids[i].id, sizeof(size_t)); + io_simple_buffer(&b, &bsz, &bmax, + &ok, sizeof(ok)); + io_simple_write(fd, b, bsz); + bsz = 0; + free(ids[i].uri); ids[i].uri = NULL; ids[i].pid = 0; @@ -363,6 +368,7 @@ proc_rsync(char *prog, char *bind_addr, int fd) free(ids[i].uri); } + free(b); free(ids); exit(rc); /* NOTREACHED */ |