[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT/NEWLIB PATCH 3/6] Add select() support via lwIP if available



Hi Florian,

Please see a single comment inline.

Thanks,

-- Felipe

On 20.05.19, 13:31, "Minios-devel on behalf of Florian Schmidt" 
<minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of 
florian.schmidt@xxxxxxxxx> wrote:

    Otherwise, provide a dummy stub.
    
    Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
    ---
     file.c             | 39 +++++++++++++++++++++++++++++++++++++++
     include/sys/poll.h |  5 +++++
     2 files changed, 44 insertions(+)
    
    diff --git a/file.c b/file.c
    index 02f1b6f..43c1bf4 100644
    --- a/file.c
    +++ b/file.c
    @@ -35,7 +35,12 @@
      * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
      */
     
    +#include <uk/config.h>
    +#include <uk/sched.h>
     #include <uk/plat/console.h>
    +#if CONFIG_LWIP_SOCKET
    +#include <lwip/sockets.h>
    +#endif
     #include <sys/stat.h>
     #include <errno.h>
     #undef errno
    @@ -66,3 +71,37 @@ int munmap(void *addr __unused, size_t len __unused)
     {
        return 0;
     }
    +
    +#if !CONFIG_LWIP_SOCKET
    +static int select_notimplemented(int nfds  __unused, fd_set *readfds 
__unused,
    +           fd_set *writefds __unused, fd_set *exceptfds __unused,
    +           struct timeval *timeout __unused)
    +{
    +   errno = EINTR;
    +   return -1;
    +}
    +#endif


> This #endif should be moved to the bottom of select(), otherwise we get a 
> clash with the select() definition in lwip's sockets.c




    +
    +int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
    +           struct timeval *timeout)
    +{
    +   uint64_t nsecs;
    +
    +   if (nfds == 0) {
    +           nsecs = timeout->tv_sec * 1000000000;
    +           nsecs += timeout->tv_usec * 1000;
    +           uk_sched_thread_sleep(nsecs);
    +           return 0;
    +   }
    +   else {
    +#if CONFIG_LWIP_SOCKET
    +           return lwip_select(nfds, readfds, writefds, exceptfds,
    +                           timeout);
    +#else
    +           /* TODO: implement */
    +           return select_notimplemented(nfds, readfds, writefds,
    +                           exceptfds, timeout);
    +#endif /* CONFIG_LWIP_SOCKET */
    +   }
    +}
    +
    diff --git a/include/sys/poll.h b/include/sys/poll.h
    index 2afbbde..556e038 100644
    --- a/include/sys/poll.h
    +++ b/include/sys/poll.h
    @@ -34,6 +34,10 @@
     #ifndef _POSIX_SYS_POLL_H_
     #define _POSIX_SYS_POLL_H_
     
    +/* LWIP's socket interface provides poll primitives */
    +#include <uk/config.h>
    +#if !CONFIG_LWIP_SOCKET
    +
     /*
      * This file is intended to be compatible with the traditional poll.h.
      */
    @@ -77,4 +81,5 @@ struct pollfd {
     
     int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout);
     
    +#endif /* !CONFIG_LWIP_SOCKET */
     #endif /* _POSIX_SYS_POLL_H_ */
    -- 
    2.21.0
    
    
    _______________________________________________
    Minios-devel mailing list
    Minios-devel@xxxxxxxxxxxxxxxxxxxx
    https://lists.xenproject.org/mailman/listinfo/minios-devel

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.