mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 14:29:39 +00:00
* sockets.c: Fix ioctl FIONREAD when some data remains from last recv.
(patch #3574).
This commit is contained in:
parent
eb28133b1f
commit
e895aa71a4
@ -117,6 +117,10 @@ HISTORY
|
||||
|
||||
++ Bug fixes:
|
||||
|
||||
2007-05-03 "maq"
|
||||
* sockets.c: Fix ioctl FIONREAD when some data remains from last recv.
|
||||
(patch #3574).
|
||||
|
||||
2007-04-23 Simon Goldschmidt
|
||||
* loopif.c, loopif.h, opt.h, src/netif/FILES: fix bug #2595: "loopif results
|
||||
in NULL reference for incoming TCP packets". Loopif has to be configured
|
||||
|
@ -1406,6 +1406,7 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
|
||||
int lwip_ioctl(int s, long cmd, void *argp)
|
||||
{
|
||||
struct lwip_socket *sock = get_socket(s);
|
||||
u16_t buflen = 0;
|
||||
|
||||
if (!sock)
|
||||
return -1;
|
||||
@ -1419,7 +1420,15 @@ int lwip_ioctl(int s, long cmd, void *argp)
|
||||
|
||||
*((u16_t*)argp) = sock->conn->recv_avail;
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
|
||||
/* Check if there is data left from the last recv operation. /maq 041215 */
|
||||
if (sock->lastdata) {
|
||||
buflen = netbuf_len(sock->lastdata);
|
||||
buflen -= sock->lastoffset;
|
||||
|
||||
*((u16_t*)argp) += buflen;
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
|
||||
sock_set_errno(sock, 0);
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user