mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Added function-like macro for struct netconn::non_blocking
This commit is contained in:
parent
e58f4c567a
commit
c70c3eac62
@ -258,7 +258,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
if (!sock)
|
if (!sock)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((sock->conn->non_blocking) && (sock->rcvevent <= 0)) {
|
if (netconn_is_nonblocking(sock->conn) && (sock->rcvevent <= 0)) {
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): returning EWOULDBLOCK\n", s));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): returning EWOULDBLOCK\n", s));
|
||||||
sock_set_errno(sock, EWOULDBLOCK);
|
sock_set_errno(sock, EWOULDBLOCK);
|
||||||
return -1;
|
return -1;
|
||||||
@ -492,7 +492,7 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
|||||||
buf = sock->lastdata;
|
buf = sock->lastdata;
|
||||||
} else {
|
} else {
|
||||||
/* If this is non-blocking call, then check first */
|
/* If this is non-blocking call, then check first */
|
||||||
if (((flags & MSG_DONTWAIT) || (sock->conn->non_blocking)) &&
|
if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) &&
|
||||||
(sock->rcvevent <= 0)) {
|
(sock->rcvevent <= 0)) {
|
||||||
if (off > 0) {
|
if (off > 0) {
|
||||||
/* already received data, return that */
|
/* already received data, return that */
|
||||||
@ -1926,6 +1926,7 @@ lwip_ioctl(int s, long cmd, void *argp)
|
|||||||
struct lwip_socket *sock = get_socket(s);
|
struct lwip_socket *sock = get_socket(s);
|
||||||
u16_t buflen = 0;
|
u16_t buflen = 0;
|
||||||
s16_t recv_avail;
|
s16_t recv_avail;
|
||||||
|
u8_t val;
|
||||||
|
|
||||||
if (!sock)
|
if (!sock)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1955,11 +1956,12 @@ lwip_ioctl(int s, long cmd, void *argp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case FIONBIO:
|
case FIONBIO:
|
||||||
if (argp && *(u32_t*)argp)
|
val = 0;
|
||||||
sock->conn->non_blocking = 1;
|
if (argp && *(u32_t*)argp) {
|
||||||
else
|
val = 1;
|
||||||
sock->conn->non_blocking = 0;
|
}
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, sock->conn->non_blocking));
|
netconn_set_nonblocking(sock->conn, val);
|
||||||
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, val));
|
||||||
sock_set_errno(sock, 0);
|
sock_set_errno(sock, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -221,8 +221,13 @@ err_t netconn_join_leave_group(struct netconn *conn, struct ip_addr *multiaddr
|
|||||||
err_t netconn_gethostbyname(const char *name, struct ip_addr *addr);
|
err_t netconn_gethostbyname(const char *name, struct ip_addr *addr);
|
||||||
#endif /* LWIP_DNS */
|
#endif /* LWIP_DNS */
|
||||||
|
|
||||||
#define netconn_err(conn) ((conn)->last_err)
|
#define netconn_err(conn) ((conn)->last_err)
|
||||||
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
|
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
|
||||||
|
|
||||||
|
/** Set the blocking status of netconn calls (@todo: write/send is missing) */
|
||||||
|
#define netconn_set_nonblocking(conn, val) ((conn)->non_blocking = (val))
|
||||||
|
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
|
||||||
|
#define netconn_is_nonblocking(conn) ((conn)->non_blocking)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user