From: claudio Date: Tue, 24 May 2022 09:20:49 +0000 (+0000) Subject: Introduce MAX_HTTP_REQUESTS and MAX_RSYNC_REQUESTS. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6e7e52893bc72b7c78f57f3856286dac13c2d5ec;p=openbsd Introduce MAX_HTTP_REQUESTS and MAX_RSYNC_REQUESTS. These just replace MAX_CONNECTIONS and MAX_RSYNC_PROCESSES to be more unified. OK tb@ --- diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h index 53d02024169..31381a396c8 100644 --- a/usr.sbin/rpki-client/extern.h +++ b/usr.sbin/rpki-client/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.137 2022/05/11 21:19:06 job Exp $ */ +/* $OpenBSD: extern.h,v 1.138 2022/05/24 09:20:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -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 diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c index fa8d1be6672..fa230e86d3e 100644 --- a/usr.sbin/rpki-client/http.c +++ b/usr.sbin/rpki-client/http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http.c,v 1.60 2022/05/15 16:43:34 tb Exp $ */ +/* $OpenBSD: http.c,v 1.61 2022/05/24 09:20:49 claudio Exp $ */ /* * Copyright (c) 2020 Nils Fisher * Copyright (c) 2020 Claudio Jeker @@ -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 *req) return 1; } - if (http_conn_count < MAX_CONNECTIONS) { + if (http_conn_count < MAX_HTTP_REQUESTS) { http_new(req); return 1; } diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c index 37f52aa800c..537822f4d78 100644 --- a/usr.sbin/rpki-client/rsync.c +++ b/usr.sbin/rpki-client/rsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsync.c,v 1.37 2022/04/20 15:38:24 deraadt Exp $ */ +/* $OpenBSD: rsync.c,v 1.38 2022/05/24 09:20:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -147,7 +147,7 @@ proc_rsync(char *prog, char *bind_addr, int fd) 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 fd) 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, int fd) 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, int fd) 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, int fd) /* 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, int fd) } /* 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);