lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] lwip_select() blocks even if timeout is 0


From: Chu, Zhenwei
Subject: RE: [lwip-users] lwip_select() blocks even if timeout is 0
Date: Mon, 6 Oct 2008 13:41:04 -0400

Yes, it is lwIP 1.3.0. timeout is set to 0, and timeout->tv_sec = 0  
and timeout->tv_usec=0. The section of code from sockets.c is copied
here.

lwip_select()
{
....

    /* add our semaphore to list */
    /* We don't actually need any dynamic memory. Our entry on the
     * list is only valid while we are in this function, so it's ok
     * to use local variables */
    
    select_cb.sem = sys_sem_new(0);
    /* Note that we are still protected */
    /* Put this select_cb on top of list */
    select_cb.next = select_cb_list;
    select_cb_list = &select_cb;
    
    /* Now we can safely unprotect */
    sys_sem_signal(selectsem);
    
    /* Now just wait to be woken */
    if (timeout == 0)
      /* Wait forever */
      msectimeout = 0;
    else {
      msectimeout =  ((timeout->tv_sec * 1000) + ((timeout->tv_usec +
500)/1000));
      if(msectimeout == 0)
        msectimeout = 1;
    }
    
    i = sys_sem_wait_timeout(select_cb.sem, msectimeout);          <----
BLOCKED HERE msectimeout=0
    
    /* Take us off the list */
    sys_sem_wait(selectsem);
    if (select_cb_list == &select_cb)
      select_cb_list = select_cb.next;
    else
      for (p_selcb = select_cb_list; p_selcb; p_selcb = p_selcb->next) {
        if (p_selcb->next == &select_cb) {
          p_selcb->next = select_cb.next;
          break;
        }
      }
    
    sys_sem_signal(selectsem);

....
}

Thanks

Zhenwei


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf
Of Rishi Khan
Sent: Monday, October 06, 2008 12:19 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip_select() blocks even if timeout is 0

By any chance, are you setting timeout to 0, or timeout->tv_sec = 0  
and timeout->tv_usec=0?
The latter is correct. The former means wait forever.

Rishi

On Oct 6, 2008, at 11:57 AM, Chu, Zhenwei wrote:

> Hi,
>
> It seems that lwIP_select() always block even if timeout is set to 0.
>
> The call stack shows it stops at
> sys_sem_wait(sem);  (line 316: sys.c)
> sys_sem_wait_timeout();
>
> Any suggestions?
>
> Thanks
>
> Zhenwei Chu
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users




reply via email to

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