mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-07 14:26:57 +00:00
Fix bug in FIONREAD handling in LINUXMODE
Fix a bug in the socket API's ioctl for FIONREAD. If the socket's lastdata was assigned the function returned without error but did not update the argument pointer. The cast type for argp was also changed to int to conform with the other SO_RCVBUF handling.
This commit is contained in:
parent
fd891081c4
commit
2a8398dfb8
@ -2621,18 +2621,20 @@ lwip_ioctl(int s, long cmd, void *argp)
|
|||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
if (sock->lastdata) {
|
if (sock->lastdata) {
|
||||||
p = ((struct netbuf *)sock->lastdata)->p;
|
p = ((struct netbuf *)sock->lastdata)->p;
|
||||||
|
*((int*)argp) = p->tot_len - sock->lastoffset;
|
||||||
} else {
|
} else {
|
||||||
struct netbuf *rxbuf;
|
struct netbuf *rxbuf;
|
||||||
err_t err;
|
err_t err;
|
||||||
if (sock->rcvevent <= 0) {
|
if (sock->rcvevent <= 0) {
|
||||||
*((u16_t*)argp) = 0;
|
*((int*)argp) = 0;
|
||||||
} else {
|
} else {
|
||||||
err = netconn_recv(sock->conn, &rxbuf);
|
err = netconn_recv(sock->conn, &rxbuf);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
*((u16_t*)argp) = 0;
|
*((int*)argp) = 0;
|
||||||
} else {
|
} else {
|
||||||
sock->lastdata = rxbuf;
|
sock->lastdata = rxbuf;
|
||||||
*((u16_t*)argp) = rxbuf->p->tot_len;
|
sock->lastoffset = 0;
|
||||||
|
*((int*)argp) = rxbuf->p->tot_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user