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: Bill Florac
Subject: RE: [lwip-devel] Netconn callback order
Date: Wed, 20 Feb 2008 12:26:25 -0600

The second proposal, passing netbuf instead of tot_len the callback, would not 
break the callback if it return a value indicating if the netbuf was used.

// API_EVENT returns true if netbuf used by call back.
if (!API_EVENT(conn, NETCONN_EVT_RCVPLUS, buf)) {
    netbuf_delete(buf);
} else {
  if (sys_mbox_trypost(conn->recvmbox, buf) != ERR_OK) {
    netbuf_delete(buf);
    return;
  }
}

This of course would break existing code unless it was wrapped in some option 
set in opt.h...


-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Jonathan Larmour
Sent: Wednesday, February 20, 2008 10:58 AM
To: lwip-devel
Subject: Re: [lwip-devel] Netconn callback order

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


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




reply via email to

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