bug-hurd
[Top][All Lists]
Advanced

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

Re: [GSoC 2017] Number for sockets


From: Kalle Olavi Niemitalo
Subject: Re: [GSoC 2017] Number for sockets
Date: Sun, 13 Aug 2017 15:13:46 +0300
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux)

Kalle Olavi Niemitalo <kon@iki.fi> writes:

> The following builds OK (also with LWIP_POLL=1 if you add
> #include <poll.h> to cc.h) but I have not run it.

Fixed a couple of bugs.  Still not run.

commit a5b178d9111d8bbc34f9a820cda56e20343fb2b0
Author:     Kalle Olavi Niemitalo <kon@iki.fi>
AuthorDate: 2017-08-13 14:43:29 +0300
Commit:     Kalle Olavi Niemitalo <kon@iki.fi>
CommitDate: 2017-08-13 15:09:57 +0300

    Fixes for lwip_poll
    
    If lwip_poll is given timeout < 0, then pass 0 to sys_arch_sem_wait_intr.
    Fix select_cb pointer type mismatches.
    Make lwip_unlink_select_cb static.
    Delete trailing whitespace.
    Delete a misleading comment about LWIP_POLLSCAN_CLEAR.
    Delete unused variables.

diff --git a/api/sockets.c b/api/sockets.c
index 86b44ab..63d2df9 100644
--- a/api/sockets.c
+++ b/api/sockets.c
@@ -245,7 +245,7 @@ struct lwip_select_cb {
   /** unimplemented: exceptset passed to select */
   fd_set *exceptset;
 #if LWIP_POLL
-  /** fds passed to poll; NULL if select */ 
+  /** fds passed to poll; NULL if select */
   struct pollfd *poll_fds;
   /** nfds passed to poll; 0 if select */
   nfds_t poll_nfds;
@@ -1387,7 +1387,7 @@ lwip_link_select_cb(struct lwip_select_cb *select_cb)
   if (select_cb_list != NULL) {
     select_cb_list->prev = select_cb;
   }
-  select_cb_list = &select_cb;
+  select_cb_list = select_cb;
   /* Increasing this counter tells event_callback that the list has changed. */
   select_cb_ctr++;
 
@@ -1396,7 +1396,7 @@ lwip_link_select_cb(struct lwip_select_cb *select_cb)
 }
 
 /* Remove select_cb from select_cb_list. */
-void
+static void
 lwip_unlink_select_cb(struct lwip_select_cb *select_cb)
 {
   SYS_ARCH_DECL_PROTECT(lev);
@@ -1406,7 +1406,7 @@ lwip_unlink_select_cb(struct lwip_select_cb *select_cb)
   if (select_cb->next != NULL) {
     select_cb->next->prev = select_cb->prev;
   }
-  if (select_cb_list == &select_cb) {
+  if (select_cb_list == select_cb) {
     LWIP_ASSERT("select_cb->prev == NULL", select_cb->prev == NULL);
     select_cb_list = select_cb->next;
   } else {
@@ -1807,12 +1807,11 @@ lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
   u32_t waitres = 0;
   int nready;
+  u32_t msectimeout;
   struct lwip_select_cb select_cb;
-  nfds_t fdi;
 #if LWIP_NETCONN_SEM_PER_THREAD
   int waited = 0;
 #endif
-  SYS_ARCH_DECL_PROTECT(lev);
 
   LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_poll(%p, %d, %d)\n",
                   (void*)fds, (int)nfds, timeout));
@@ -1860,16 +1859,22 @@ lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 
     if (!nready) {
       /* Still none ready, just wait to be woken */
-      waitres = sys_arch_sem_wait_intr(SELECT_SEM_PTR(select_cb.sem), timeout);
+      if (timeout < 0) {
+        /* Wait forever */
+        msectimeout = 0;
+      } else {
+        /* timeout == 0 would have been handled earlier. */
+        LWIP_ASSERT("timeout > 0", timeout > 0);
+        msectimeout = timeout;
+      }
+      waitres = sys_arch_sem_wait_intr(SELECT_SEM_PTR(select_cb.sem), 
msectimeout);
 #if LWIP_NETCONN_SEM_PER_THREAD
       waited = 1;
 #endif
     }
 
     /* Decrease select_waiting for each socket we are interested in,
-       and check which events occurred while we waited.
-       It is OK to discard the previous value of nready because
-       we don't set LWIP_POLLSCAN_CLEAR. */
+       and check which events occurred while we waited. */
     nready = lwip_pollscan(fds, nfds, LWIP_POLLSCAN_DEC_WAIT);
 
     lwip_unlink_select_cb(&select_cb);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]