lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Netconn callback order


From: Jonathan Larmour
Subject: Re: [lwip-devel] Netconn callback order
Date: Wed, 20 Feb 2008 16:58:02 +0000
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Bill Florac wrote:
> Is there a reason why the callback from netconn_new_with_callback() must
> occur before the data is put into the mailbox rather than after
> (recv_udp() function in api_msg.c)?  I would like to make the receiving
> of packets (UDP) event based rather than have to poll and wait for them.
> If the callback occurs after the posting then I could get the data from
> the callback. Or, better yet, pass a pointer to the netbuf in the
> callback and return a flag if the data has been eaten skipping the
> mailbox all together.

The primary user of callback stuff is select() in the sockets API. I think
it's this way round to avoid a race condition where a socket gets data read
from it before the select. The relevant bit being that there's a RCVMINUS
event on a successful read, and a RCVPLUS when data arrives. In
event_callback() in sockets.c, these are used to set sock->rcvevent which
is essentially the number of pbufs waiting to be read.

If what you proposed were implemented then depending on when threads run, I
believe sock->rcvevent could wrap around, breaking event_callback().

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
Visit us @ Embedded World 2008, Nürnberg, Germany, 26-28 Feb:Stand 11-336
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

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