mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 03:35:38 +00:00
Remove netconn_recved() call - it was only needed in sockets implementation and contributed to bug #47512
Simon and I think it can be removed - the receive window handling get a little less precise, but that should be OK for a lightweight stack. Receive window is now updated with the whole pbuf size (instead of only count of read bytes from socket) as soon as socket implementation gets a pbuf from netconn layer. Work on bug #47512: MPU_COMPATIBLE may fail on empty pool (still not finished)
This commit is contained in:
parent
21354af674
commit
e653ac9db7
@ -486,22 +486,21 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
|
||||
if (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP)
|
||||
#endif /* (LWIP_UDP || LWIP_RAW) */
|
||||
{
|
||||
if (!netconn_get_noautorecved(conn) || (buf == NULL)) {
|
||||
/* Let the stack know that we have taken the data. */
|
||||
/* TODO: Speedup: Don't block and wait for the answer here
|
||||
(to prevent multiple thread-switches). */
|
||||
API_MSG_VAR_ALLOC_DONTFAIL(msg);
|
||||
API_MSG_VAR_REF(msg).conn = conn;
|
||||
if (buf != NULL) {
|
||||
API_MSG_VAR_REF(msg).msg.r.len = ((struct pbuf *)buf)->tot_len;
|
||||
} else {
|
||||
API_MSG_VAR_REF(msg).msg.r.len = 1;
|
||||
}
|
||||
/* don't care for the return value of lwip_netconn_do_recv */
|
||||
netconn_apimsg(lwip_netconn_do_recv, &API_MSG_VAR_REF(msg));
|
||||
API_MSG_VAR_FREE(msg);
|
||||
/* Let the stack know that we have taken the data. */
|
||||
/* TODO: Speedup: Don't block and wait for the answer here
|
||||
(to prevent multiple thread-switches). */
|
||||
API_MSG_VAR_ALLOC_DONTFAIL(msg);
|
||||
API_MSG_VAR_REF(msg).conn = conn;
|
||||
if (buf != NULL) {
|
||||
API_MSG_VAR_REF(msg).msg.r.len = ((struct pbuf *)buf)->tot_len;
|
||||
} else {
|
||||
API_MSG_VAR_REF(msg).msg.r.len = 1;
|
||||
}
|
||||
|
||||
/* don't care for the return value of lwip_netconn_do_recv */
|
||||
netconn_apimsg(lwip_netconn_do_recv, &API_MSG_VAR_REF(msg));
|
||||
API_MSG_VAR_FREE(msg);
|
||||
|
||||
/* If we are closed, we indicate that we no longer wish to use the socket */
|
||||
if (buf == NULL) {
|
||||
API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
|
||||
@ -613,39 +612,6 @@ netconn_recv(struct netconn *conn, struct netbuf **new_buf)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TCP: update the receive window: by calling this, the application
|
||||
* tells the stack that it has processed data and is able to accept
|
||||
* new data.
|
||||
* ATTENTION: use with care, this is mainly used for sockets!
|
||||
* Can only be used when calling netconn_set_noautorecved(conn, 1) before.
|
||||
*
|
||||
* @param conn the netconn for which to update the receive window
|
||||
* @param length amount of data processed (ATTENTION: this must be accurate!)
|
||||
*/
|
||||
void
|
||||
netconn_recved(struct netconn *conn, u32_t length)
|
||||
{
|
||||
#if LWIP_TCP
|
||||
if ((conn != NULL) && (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP) &&
|
||||
(netconn_get_noautorecved(conn))) {
|
||||
API_MSG_VAR_DECLARE(msg);
|
||||
/* Let the stack know that we have taken the data. */
|
||||
/* TODO: Speedup: Don't block and wait for the answer here
|
||||
(to prevent multiple thread-switches). */
|
||||
API_MSG_VAR_ALLOC_DONTFAIL(msg);
|
||||
API_MSG_VAR_REF(msg).conn = conn;
|
||||
API_MSG_VAR_REF(msg).msg.r.len = length;
|
||||
/* don't care for the return value of lwip_netconn_do_recv */
|
||||
netconn_apimsg(lwip_netconn_do_recv, &API_MSG_VAR_REF(msg));
|
||||
API_MSG_VAR_FREE(msg);
|
||||
}
|
||||
#else /* LWIP_TCP */
|
||||
LWIP_UNUSED_ARG(conn);
|
||||
LWIP_UNUSED_ARG(length);
|
||||
#endif /* LWIP_TCP */
|
||||
}
|
||||
|
||||
/**
|
||||
* Send data (in form of a netbuf) to a specific remote IP address and port.
|
||||
* Only to be used for UDP and RAW netconns (not TCP).
|
||||
|
@ -522,8 +522,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
return -1;
|
||||
}
|
||||
LWIP_ASSERT("newconn != NULL", newconn != NULL);
|
||||
/* Prevent automatic window updates, we do this on our own! */
|
||||
netconn_set_noautorecved(newconn, 1);
|
||||
|
||||
newsock = alloc_socket(newconn, 1);
|
||||
if (newsock == -1) {
|
||||
@ -774,8 +772,6 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) &&
|
||||
(sock->rcvevent <= 0)) {
|
||||
if (off > 0) {
|
||||
/* update receive window */
|
||||
netconn_recved(sock->conn, (u32_t)off);
|
||||
/* already received data, return that */
|
||||
sock_set_errno(sock, 0);
|
||||
return off;
|
||||
@ -797,8 +793,6 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
|
||||
if (err != ERR_OK) {
|
||||
if (off > 0) {
|
||||
/* update receive window */
|
||||
netconn_recved(sock->conn, (u32_t)off);
|
||||
if (err == ERR_CLSD) {
|
||||
/* closed but already received data, ensure select gets the FIN, too */
|
||||
event_callback(sock->conn, NETCONN_EVT_RCVPLUS, 0);
|
||||
@ -913,11 +907,6 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
if ((off > 0) && (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP) &&
|
||||
((flags & MSG_PEEK) == 0)) {
|
||||
/* update receive window */
|
||||
netconn_recved(sock->conn, (u32_t)off);
|
||||
}
|
||||
sock_set_errno(sock, 0);
|
||||
return off;
|
||||
}
|
||||
@ -1234,10 +1223,6 @@ lwip_socket(int domain, int type, int protocol)
|
||||
conn = netconn_new_with_callback(DOMAIN_TO_NETCONN_TYPE(domain, NETCONN_TCP), event_callback);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ",
|
||||
domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
|
||||
if (conn != NULL) {
|
||||
/* Prevent automatic window updates, we do this on our own! */
|
||||
netconn_set_noautorecved(conn, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n",
|
||||
|
@ -65,9 +65,6 @@ extern "C" {
|
||||
#define NETCONN_FLAG_NON_BLOCKING 0x02
|
||||
/** Was the last connect action a non-blocking one? */
|
||||
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
|
||||
/** If this is set, a TCP netconn must call netconn_recved() to update
|
||||
the TCP receive window (done automatically if not set). */
|
||||
#define NETCONN_FLAG_NO_AUTO_RECVED 0x08
|
||||
/** If a nonblocking write has been rejected before, poll_tcp needs to
|
||||
check if the netconn is writable again */
|
||||
#define NETCONN_FLAG_CHECK_WRITESPACE 0x10
|
||||
@ -271,7 +268,6 @@ err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
|
||||
err_t netconn_accept(struct netconn *conn, struct netconn **new_conn);
|
||||
err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf);
|
||||
err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
|
||||
void netconn_recved(struct netconn *conn, u32_t length);
|
||||
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
||||
const ip_addr_t *addr, u16_t port);
|
||||
err_t netconn_send(struct netconn *conn, struct netbuf *buf);
|
||||
@ -307,14 +303,6 @@ err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
|
||||
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
|
||||
#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
|
||||
|
||||
/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
||||
#define netconn_set_noautorecved(conn, val) do { if(val) { \
|
||||
(conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \
|
||||
} else { \
|
||||
(conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0)
|
||||
/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
||||
#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
|
||||
|
||||
#if LWIP_IPV6
|
||||
/** TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) */
|
||||
#define netconn_set_ipv6only(conn, val) do { if(val) { \
|
||||
|
Loading…
x
Reference in New Issue
Block a user