[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT/LWIP PATCH] sockets.c: Add ppoll() function
Apparently, as this function is non-standard, there are multiple implementations (and, thus, multiple explanations in man pages) and blocking indefinitely is okay. Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@xxxxxxxxx> On Mon, Nov 25, 2019 at 3:48 PM Stefan Teodorescu <stefanl.teodorescu@xxxxxxxxx> wrote: > > Looks good to me, as this is the same code as described in the man > page of ppoll. I have a mention that, below this code, it is stated > that: > > The above code segment is described as nearly equivalent > because whereas a negative timeout value for poll() > is interpreted as an infinite timeout, a negative value > expressed in *tmo_p results in an error from > ppoll(). > > I believe this case should also be treated, right? The man page says > below that the function should return -1 in that case and set errno to > > EINVAL (ppoll()) The timeout value expressed in *ip is invalid > (negative). > > Stefan > > On Mon, Nov 25, 2019 at 9:47 AM Costin Lupu <costin.lupu@xxxxxxxxx> wrote: > > > > This ppoll() implementation is adapted from its man page. > > > > Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> > > --- > > Config.uk | 6 ++++++ > > sockets.c | 26 ++++++++++++++++++++++++++ > > 2 files changed, 32 insertions(+) > > > > diff --git a/Config.uk b/Config.uk > > index 8f501fc..debf0c7 100644 > > --- a/Config.uk > > +++ b/Config.uk > > @@ -170,6 +170,12 @@ if LWIP_SOCKET > > lwip's select() implementation supports only > > sockets. This > > configuration option makes it possible to use other > > file descriptor > > types as well, even though they are not supported > > by lwip. > > + > > + config LWIP_SOCKET_PPOLL > > + bool "Enable ppoll()" > > + default y > > + help > > + Enable ppoll() implementation. > > endif > > > > menuconfig LWIP_DEBUG > > diff --git a/sockets.c b/sockets.c > > index c2cf57f..5b499af 100644 > > --- a/sockets.c > > +++ b/sockets.c > > @@ -34,7 +34,11 @@ > > */ > > > > /* network stub calls */ > > +#include <uk/config.h> > > #include <sys/time.h> > > +#if CONFIG_LWIP_SOCKET_PPOLL > > +#include <signal.h> > > +#endif > > #include <vfscore/dentry.h> > > #include <vfscore/file.h> > > #include <vfscore/fs.h> > > @@ -473,6 +477,28 @@ EXIT: > > return ret; > > } > > > > +#if CONFIG_LWIP_SOCKET_PPOLL > > +#if CONFIG_LIBPTHREAD_EMBEDDED > > +#define __sigmask pthread_sigmask > > +#else > > +#define __sigmask sigprocmask > > +#endif > > +int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, > > + const sigset_t *sigmask) > > +{ > > + sigset_t origmask; > > + int timeout, rc; > > + > > + timeout = (tmo_p == NULL) ? -1 : > > + (tmo_p->tv_sec * 1000 + tmo_p->tv_nsec / 1000000); > > + __sigmask(SIG_SETMASK, sigmask, &origmask); > > + rc = poll(fds, nfds, timeout); > > + __sigmask(SIG_SETMASK, &origmask, NULL); > > + > > + return rc; > > +} > > +#endif /* CONFIG_LWIP_SOCKET_PPOLL */ > > + > > int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, > > struct timeval *timeout) > > { > > -- > > 2.20.1 > > _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |