diff options
author | Chris Johns <chrisj@rtems.org> | 2023-05-15 14:05:40 -1000 |
---|---|---|
committer | KinseyMoore <48726349+KinseyMoore@users.noreply.github.com> | 2023-05-15 21:45:54 -0500 |
commit | dd429d30862f294fa24f7fc96901912d6bcb07b0 (patch) | |
tree | f09f889b40716bbcf003e785639c95edea981237 | |
parent | bsd/ntp: Add ntpq command (diff) | |
download | rtems-net-services-dd429d30862f294fa24f7fc96901912d6bcb07b0.tar.bz2 |
ntpd: Fix select to support available fds
-rw-r--r-- | bsd/freebsd/contrib/ntp/ntpd/ntp_io.c | 17 | ||||
-rw-r--r-- | bsd/freebsd/contrib/ntp/ntpd/ntpd.c | 1 |
2 files changed, 10 insertions, 8 deletions
diff --git a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c index 2a19e9e..448a2d9 100644 --- a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c +++ b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c @@ -199,17 +199,17 @@ static struct refclockio *refio; */ #ifdef __rtems__ #include <rtems/libio_.h> +static size_t rtems_ntpd_fds_size; static int rtems_fd_set_alloc(fd_set **setp) { - static size_t _fds_size; if (*setp == NULL) { - _fds_size = sizeof(fd_set) * (howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)); - *setp = malloc(_fds_size); + rtems_ntpd_fds_size = sizeof(fd_set) * (howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)); + *setp = malloc(rtems_ntpd_fds_size); if (*setp == NULL) { errno = ENOMEM; return -1; } + memset(*setp, 0, rtems_ntpd_fds_size); } - memset(*setp, 0, _fds_size); return 0; } #define activefds (*activefds_prealloc) @@ -3646,18 +3646,19 @@ io_handler(void) #if __rtems__ #define rdfdes (*rdfdes_prealloc) static fd_set *rdfdes_prealloc; -#else +#else /* __rtems__ */ fd_set rdfdes; -#endif +#endif /* __rtems__ */ int nfound; #if __rtems__ if (rtems_fd_set_alloc(&rdfdes_prealloc) < 0) { return; } -#else + memset(rdfdes_prealloc, 0, rtems_ntpd_fds_size); +#else /* __rtems__ */ FD_ZERO(&set); -#endif +#endif /* __rtems__ */ /* * Use select() on all on all input fd's for unlimited diff --git a/bsd/freebsd/contrib/ntp/ntpd/ntpd.c b/bsd/freebsd/contrib/ntp/ntpd/ntpd.c index e9e1ba5..b5086d1 100644 --- a/bsd/freebsd/contrib/ntp/ntpd/ntpd.c +++ b/bsd/freebsd/contrib/ntp/ntpd/ntpd.c @@ -153,6 +153,7 @@ #endif #else /* __rtems__ */ #include <rtems/ntpd.h> +#include <machine/rtems-bsd-program.h> #endif /* __rtems__ */ #ifdef HAVE_DNSREGISTRATION |