On Fri, Sep 02, 2022 at 08:49:12PM +0200, Claudio Jeker wrote: > This diff uses the now available aborts to stop repository > synchronisations once the timeout is hit. > > I played with very short repo_timeouts and it seems to work better then > what we have now.
I generally prefer explicit checks against NULL, but it's done this way in the entire file. ok > -- > :wq Claudio > > ? obj > Index: extern.h > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v > retrieving revision 1.152 > diff -u -p -r1.152 extern.h > --- extern.h 2 Sep 2022 18:37:17 -0000 1.152 > +++ extern.h 2 Sep 2022 18:47:16 -0000 > @@ -653,9 +653,11 @@ void rrdp_finish(unsigned int, int); > > void rsync_fetch(unsigned int, const char *, const char *, > const char *); > +void rsync_abort(unsigned int); > void http_fetch(unsigned int, const char *, const char *, int); > void rrdp_fetch(unsigned int, const char *, const char *, > struct rrdp_session *); > +void rrdp_abort(unsigned int); > void rrdp_http_done(unsigned int, enum http_result, const char *); > int repo_check_timeout(int); > > Index: main.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v > retrieving revision 1.215 > diff -u -p -r1.215 main.c > --- main.c 30 Aug 2022 22:42:32 -0000 1.215 > +++ main.c 2 Sep 2022 18:47:16 -0000 > @@ -256,6 +256,18 @@ rrdp_fetch(unsigned int id, const char * > io_close_buffer(&rrdpq, b); > } > > +void > +rrdp_abort(unsigned int id) > +{ > + enum rrdp_msg type = RRDP_ABORT; > + struct ibuf *b; > + > + b = io_new_buffer(); > + io_simple_buffer(b, &type, sizeof(type)); > + io_simple_buffer(b, &id, sizeof(id)); > + io_close_buffer(&rrdpq, b); > +} > + > /* > * Request a repository sync via rsync URI to directory local. > */ > @@ -270,6 +282,19 @@ rsync_fetch(unsigned int id, const char > io_str_buffer(b, local); > io_str_buffer(b, base); > io_str_buffer(b, uri); > + io_close_buffer(&rsyncq, b); > +} > + > +void > +rsync_abort(unsigned int id) > +{ > + struct ibuf *b; > + > + b = io_new_buffer(); > + io_simple_buffer(b, &id, sizeof(id)); > + io_str_buffer(b, NULL); > + io_str_buffer(b, NULL); > + io_str_buffer(b, NULL); > io_close_buffer(&rsyncq, b); > } > > Index: repo.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/repo.c,v > retrieving revision 1.37 > diff -u -p -r1.37 repo.c > --- repo.c 2 Sep 2022 15:09:19 -0000 1.37 > +++ repo.c 2 Sep 2022 18:47:17 -0000 > @@ -1204,6 +1204,20 @@ repo_fail(struct repo *rp) > errx(1, "%s: bad repo", rp->repouri); > } > > +static void > +repo_abort(struct repo *rp) > +{ > + /* reset the alarm */ > + rp->alarm = getmonotime() + repo_timeout; > + > + if (rp->rsync) > + rsync_abort(rp->rsync->id); > + else if (rp->rrdp) > + rrdp_abort(rp->rrdp->id); > + else > + repo_fail(rp); > +} > + > int > repo_check_timeout(int timeout) > { > @@ -1217,7 +1231,7 @@ repo_check_timeout(int timeout) > if (rp->alarm <= now) { > warnx("%s: synchronisation timeout", > rp->repouri); > - repo_fail(rp); > + repo_abort(rp); > } else { > int diff = rp->alarm - now; > diff *= 1000; >