mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +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
|
err_t
|
||||||
netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf)
|
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;);
|
NETCONNTYPE_GROUP(netconn_type(conn)) == NETCONN_TCP, return ERR_ARG;);
|
||||||
|
|
||||||
return netconn_recv_data(conn, (void **)new_buf);
|
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
|
* @ingroup netconn_common
|
||||||
* Receive data (in form of a netbuf containing a packet buffer) from a netconn
|
* 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) {
|
if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP) {
|
||||||
err = netconn_recv_tcp_pbuf(sock->conn, (struct pbuf **)&buf);
|
err = netconn_recv_tcp_pbuf(sock->conn, (struct pbuf **)&buf);
|
||||||
} else {
|
} 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",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: netconn_recv err=%d, netbuf=%p\n",
|
||||||
err, buf));
|
err, buf));
|
||||||
@ -2636,7 +2636,7 @@ lwip_ioctl(int s, long cmd, void *argp)
|
|||||||
if (sock->rcvevent <= 0) {
|
if (sock->rcvevent <= 0) {
|
||||||
*((int*)argp) = 0;
|
*((int*)argp) = 0;
|
||||||
} else {
|
} else {
|
||||||
err = netconn_recv(sock->conn, &rxbuf);
|
err = netconn_recv_udp_raw_netbuf(sock->conn, &rxbuf);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
*((int*)argp) = 0;
|
*((int*)argp) = 0;
|
||||||
} else {
|
} 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)
|
#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_accept(struct netconn *conn, struct netconn **new_conn);
|
||||||
err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf);
|
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_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
|
||||||
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
||||||
const ip_addr_t *addr, u16_t port);
|
const ip_addr_t *addr, u16_t port);
|
||||||
|
Loading…
Reference in New Issue
Block a user