On Thu, Nov 04, 2021 at 06:18:59PM +0100, Claudio Jeker wrote:
> This diff replaces the errx() call in the poll fd check with warnings plus
> an exit of the main event loop. It also prints an error in case not all
> files have been processed.
> 
> An example after kill -9 of the rsync process is:
> rpki-client: https://rrdp.lacnic.net/rrdp/notification.xml: loaded from 
> network
> rpki-client: poll[1]: hangup
> rpki-client: rsync terminated signal 9
> rpki-client: not all files processed, giving up
> 
> I find this better.

Yes, that's nicer.

ok tb

> -- 
> :wq Claudio
> 
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> retrieving revision 1.162
> diff -u -p -r1.162 main.c
> --- main.c    4 Nov 2021 14:24:41 -0000       1.162
> +++ main.c    4 Nov 2021 17:12:27 -0000
> @@ -1020,8 +1020,10 @@ main(int argc, char *argv[])
>               }
>  
>               for (i = 0; i < NPFD; i++) {
> -                     if (pfd[i].revents & (POLLERR|POLLNVAL))
> -                             errx(1, "poll[%zu]: bad fd", i);
> +                     if (pfd[i].revents & (POLLERR|POLLNVAL)) {
> +                             warnx("poll[%zu]: bad fd", i);
> +                             hangup = 1;
> +                     }
>                       if (pfd[i].revents & POLLHUP) {
>                               warnx("poll[%zu]: hangup", i);
>                               hangup = 1;
> @@ -1029,10 +1031,14 @@ main(int argc, char *argv[])
>                       if (pfd[i].revents & POLLOUT) {
>                               switch (msgbuf_write(queues[i])) {
>                               case 0:
> -                                     errx(1, "write[%zu]: "
> +                                     warnx("write[%zu]: "
>                                           "connection closed", i);
> +                                     hangup = 1;
> +                                     break;
>                               case -1:
> -                                     err(1, "write[%zu]", i);
> +                                     warnx("write[%zu]", i);
> +                                     hangup = 1;
> +                                     break;
>                               }
>                       }
>               }
> @@ -1147,7 +1153,7 @@ main(int argc, char *argv[])
>  
>       /* processing did not finish because of error */
>       if (entity_queue != 0)
> -             return 1;
> +             errx(1, "not all files processed, giving up");
>  
>       logx("all files parsed: generating output");
>  
> 

Reply via email to