diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-01-23 12:09:25 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-01-23 12:09:25 +0000 |
commit | dc58e2f7879c9c742c97133bce965ef4db714992 (patch) | |
tree | 26466c595d3117be4cdbda6d7f46944472b2ea1a /usr.sbin/rpki-client/repo.c | |
parent | 2e390d18d51f0a8f5652ac5aabbdfd104e9dc3fb (diff) |
Handle EINTR the same way in all poll loops. In all cases restart the
poll loop. In the main process move the timeout handling for repositories
into a single function that does the timeouts and the calculation of the
timeout in one go.
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client/repo.c')
-rw-r--r-- | usr.sbin/rpki-client/repo.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 773290dc055..7242ed24536 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.25 2022/01/14 15:00:23 claudio Exp $ */ +/* $OpenBSD: repo.c,v 1.26 2022/01/23 12:09:24 claudio Exp $ */ /* * Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> @@ -1165,27 +1165,6 @@ repo_queued(struct repo *rp, struct entity *p) return 0; } -int -repo_next_timeout(int timeout) -{ - struct repo *rp; - time_t now; - - now = getmonotime(); - /* Look up in repository table. (Lookup should actually fail here) */ - SLIST_FOREACH(rp, &repos, entry) { - if (repo_state(rp) == REPO_LOADING) { - int diff = rp->alarm - now; - if (diff < 0) - diff = 0; - diff *= 1000; - if (timeout == INFTIM || diff < timeout) - timeout = diff; - } - } - return timeout; -} - static void repo_fail(struct repo *rp) { @@ -1202,8 +1181,8 @@ repo_fail(struct repo *rp) errx(1, "%s: bad repo", rp->repouri); } -void -repo_check_timeout(void) +int +repo_check_timeout(int timeout) { struct repo *rp; time_t now; @@ -1216,9 +1195,15 @@ repo_check_timeout(void) warnx("%s: synchronisation timeout", rp->repouri); repo_fail(rp); + } else { + int diff = rp->alarm - now; + diff *= 1000; + if (timeout == INFTIM || diff < timeout) + timeout = diff; } } } + return timeout; } static char ** |