On Tue, May 24, 2022 at 10:03:31AM +0200, Claudio Jeker wrote: > This diff moves and renames the defines that define the maximum number of > parallel requests for http and rsync. > The defines are now MAX_HTTP_REQUESTS and MAX_RSYNC_REQUESTS the values > remane the same.
ok > Also move the memset of pollfd sets in http.c into the loop. It is not > needed but I prefer it that way. Also ok. I would commit this separately as it is completely unrelated. > > -- > :wq Claudio > > Index: extern.h > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v > retrieving revision 1.137 > diff -u -p -r1.137 extern.h > --- extern.h 11 May 2022 21:19:06 -0000 1.137 > +++ extern.h 24 May 2022 07:44:22 -0000 > @@ -702,8 +702,9 @@ int mkpathat(int, const char *); > /* Maximum depth of the RPKI tree. */ > #define MAX_CERT_DEPTH 12 > > -/* Maximum number of concurrent rsync processes. */ > -#define MAX_RSYNC_PROCESSES 16 > +/* Maximum number of concurrent http and rsync requests. */ > +#define MAX_HTTP_REQUESTS 64 > +#define MAX_RSYNC_REQUESTS 16 > > /* Maximum allowd repositories per tal */ > #define MAX_REPO_PER_TAL 1000 > Index: http.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v > retrieving revision 1.60 > diff -u -p -r1.60 http.c > --- http.c 15 May 2022 16:43:34 -0000 1.60 > +++ http.c 24 May 2022 07:44:22 -0000 > @@ -71,9 +71,8 @@ > #define HTTP_BUF_SIZE (32 * 1024) > #define HTTP_IDLE_TIMEOUT 10 > #define HTTP_IO_TIMEOUT (3 * 60) > -#define MAX_CONNECTIONS 64 > #define MAX_CONTENTLEN (2 * 1024 * 1024 * 1024LL) > -#define NPFDS (MAX_CONNECTIONS + 1) > +#define NPFDS (MAX_HTTP_REQUESTS + 1) > > enum res { > DONE, > @@ -620,7 +619,7 @@ http_req_schedule(struct http_request *r > return 1; > } > > - if (http_conn_count < MAX_CONNECTIONS) { > + if (http_conn_count < MAX_HTTP_REQUESTS) { > http_new(req); > return 1; > } > @@ -1793,8 +1792,6 @@ proc_http(char *bind_addr, int fd) > if (pledge("stdio inet dns recvfd", NULL) == -1) > err(1, "pledge"); > > - memset(&pfds, 0, sizeof(pfds)); > - > msgbuf_init(&msgq); > msgq.fd = fd; > > @@ -1803,6 +1800,7 @@ proc_http(char *bind_addr, int fd) > int timeout; > size_t i; > > + memset(&pfds, 0, sizeof(pfds)); > pfds[0].fd = fd; > pfds[0].events = POLLIN; > if (msgq.queued) > Index: rsync.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/rsync.c,v > retrieving revision 1.37 > diff -u -p -r1.37 rsync.c > --- rsync.c 20 Apr 2022 15:38:24 -0000 1.37 > +++ rsync.c 24 May 2022 07:44:22 -0000 > @@ -147,7 +147,7 @@ proc_rsync(char *prog, char *bind_addr, > struct msgbuf msgq; > struct ibuf *b, *inbuf = NULL; > sigset_t mask, oldmask; > - struct rsyncproc ids[MAX_RSYNC_PROCESSES] = { 0 }; > + struct rsyncproc ids[MAX_RSYNC_REQUESTS] = { 0 }; > > if (pledge("stdio rpath proc exec unveil", NULL) == -1) > err(1, "pledge"); > @@ -211,7 +211,7 @@ proc_rsync(char *prog, char *bind_addr, > int st; > > pfd.events = 0; > - if (nprocs < MAX_RSYNC_PROCESSES) > + if (nprocs < MAX_RSYNC_REQUESTS) > pfd.events |= POLLIN; > if (msgq.queued) > pfd.events |= POLLOUT; > @@ -230,10 +230,10 @@ proc_rsync(char *prog, char *bind_addr, > while ((pid = waitpid(WAIT_ANY, &st, WNOHANG)) > 0) { > int ok = 1; > > - for (i = 0; i < MAX_RSYNC_PROCESSES; i++) > + for (i = 0; i < MAX_RSYNC_REQUESTS; i++) > if (ids[i].pid == pid) > break; > - if (i >= MAX_RSYNC_PROCESSES) > + if (i >= MAX_RSYNC_REQUESTS) > errx(1, "waitpid: %d unexpected", pid); > > if (!WIFEXITED(st)) { > @@ -278,7 +278,7 @@ proc_rsync(char *prog, char *bind_addr, > > if (!(pfd.revents & POLLIN)) > continue; > - if (nprocs >= MAX_RSYNC_PROCESSES) > + if (nprocs >= MAX_RSYNC_REQUESTS) > continue; > > b = io_buf_read(fd, &inbuf); > @@ -340,10 +340,10 @@ proc_rsync(char *prog, char *bind_addr, > > /* Augment the list of running processes. */ > > - for (i = 0; i < MAX_RSYNC_PROCESSES; i++) > + for (i = 0; i < MAX_RSYNC_REQUESTS; i++) > if (ids[i].pid == 0) > break; > - assert(i < MAX_RSYNC_PROCESSES); > + assert(i < MAX_RSYNC_REQUESTS); > ids[i].id = id; > ids[i].pid = pid; > ids[i].uri = uri; > @@ -356,7 +356,7 @@ proc_rsync(char *prog, char *bind_addr, > } > > /* No need for these to be hanging around. */ > - for (i = 0; i < MAX_RSYNC_PROCESSES; i++) > + for (i = 0; i < MAX_RSYNC_REQUESTS; i++) > if (ids[i].pid != 0) { > kill(ids[i].pid, SIGTERM); > free(ids[i].uri); >