mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Tiny speed/size improvement: don't check netconn_type twice on socket-receive
This commit is contained in:
parent
a3fc38037a
commit
4a9db56f4c
@ -606,12 +606,30 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
|
||||
err_t
|
||||
netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf)
|
||||
{
|
||||
LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL) &&
|
||||
LWIP_ERROR("netconn_recv_tcp_pbuf: invalid conn", (conn != NULL) &&
|
||||
NETCONNTYPE_GROUP(netconn_type(conn)) == NETCONN_TCP, return ERR_ARG;);
|
||||
|
||||
return netconn_recv_data(conn, (void **)new_buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive data (in form of a netbuf) from a UDP or RAW netconn
|
||||
*
|
||||
* @param conn the netconn from which to receive data
|
||||
* @param new_buf pointer where a new netbuf is stored when received data
|
||||
* @return ERR_OK if data has been received, an error code otherwise (timeout,
|
||||
* memory error or another error)
|
||||
* ERR_ARG if conn is not a UDP/RAW netconn
|
||||
*/
|
||||
err_t
|
||||
netconn_recv_udp_raw_netbuf(struct netconn *conn, struct netbuf **new_buf)
|
||||
{
|
||||
LWIP_ERROR("netconn_recv_udp_raw_netbuf: invalid conn", (conn != NULL) &&
|
||||
NETCONNTYPE_GROUP(netconn_type(conn)) != NETCONN_TCP, return ERR_ARG;);
|
||||
|
||||
return netconn_recv_data(conn, (void **)new_buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup netconn_common
|
||||
* Receive data (in form of a netbuf containing a packet buffer) from a netconn
|
||||
|
@ -775,7 +775,7 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP) {
|
||||
err = netconn_recv_tcp_pbuf(sock->conn, (struct pbuf **)&buf);
|
||||
} else {
|
||||
err = netconn_recv(sock->conn, (struct netbuf **)&buf);
|
||||
err = netconn_recv_udp_raw_netbuf(sock->conn, (struct netbuf **)&buf);
|
||||
}
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: netconn_recv err=%d, netbuf=%p\n",
|
||||
err, buf));
|
||||
@ -2636,7 +2636,7 @@ lwip_ioctl(int s, long cmd, void *argp)
|
||||
if (sock->rcvevent <= 0) {
|
||||
*((int*)argp) = 0;
|
||||
} else {
|
||||
err = netconn_recv(sock->conn, &rxbuf);
|
||||
err = netconn_recv_udp_raw_netbuf(sock->conn, &rxbuf);
|
||||
if (err != ERR_OK) {
|
||||
*((int*)argp) = 0;
|
||||
} else {
|
||||
|
@ -313,6 +313,7 @@ err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
|
||||
#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_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_udp_raw_netbuf(struct netconn *conn, struct netbuf **new_buf);
|
||||
err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
|
||||
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
||||
const ip_addr_t *addr, u16_t port);
|
||||
|
Loading…
Reference in New Issue
Block a user