Skip to content

Commit

Permalink
SMSTCPIP: backported patch for bug #23240 (2009-07-09) - recv_udp inc…
Browse files Browse the repository at this point in the history
…reases counters for available receives before netbuf is actually posted.
  • Loading branch information
sp193 committed Feb 12, 2019
1 parent b01706e commit 68d3aa9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/network/SMSTCPIP/include/lwip/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct netconn
sys_mbox_t acceptmbox;
sys_sem_t sem;
int socket;
u16_t recv_avail;
s16_t recv_avail;
void (*callback)(struct netconn *, enum netconn_evt, u16_t len);
};

Expand Down
8 changes: 4 additions & 4 deletions modules/network/SMSTCPIP/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct lwip_socket
struct netconn *conn;
struct netbuf *lastdata;
u16_t lastoffset;
u16_t rcvevent;
s16_t rcvevent;
u16_t sendevent;
u16_t flags;
int err;
Expand Down Expand Up @@ -364,7 +364,7 @@ int lwip_recvfrom(int s, void *header, int index, void *payload, int plen, unsig
buf = sock->lastdata;
} else {
/* If this is non-blocking call, then check first */
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent) {
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && (sock->rcvevent <= 0)) {
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
sock_set_errno(sock, EWOULDBLOCK);
return -1;
Expand Down Expand Up @@ -628,7 +628,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
if (FD_ISSET(i, readset)) {
/* See if netconn of this socket is ready for read */
p_sock = get_socket(i);
if (p_sock && (p_sock->lastdata || p_sock->rcvevent)) {
if (p_sock && (p_sock->lastdata || (p_sock->rcvevent > 0))) {
FD_SET(i, &lreadset);
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
nready++;
Expand Down Expand Up @@ -853,7 +853,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
if (scb->sem_signalled == 0) {
/* Test this select call for our socket */
if (scb->readset && FD_ISSET(s, scb->readset))
if (sock->rcvevent)
if (sock->rcvevent > 0)
break;
if (scb->writeset && FD_ISSET(s, scb->writeset))
if (sock->sendevent)
Expand Down

0 comments on commit 68d3aa9

Please sign in to comment.