fjpanag commented on code in PR #7286: URL: https://github.com/apache/incubator-nuttx/pull/7286#discussion_r993898747
########## net/tcp/tcp_recvfrom.c: ########## @@ -698,43 +699,53 @@ ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR struct msghdr *msg, /* We get here when we we decide that we need to setup the wait for * incoming TCP/IP data. Just a few more conditions to check: * - * 1) Make sure thet there is buffer space to receive additional data + * 1) Make sure that there is buffer space to receive additional data * (state.ir_buflen > 0). This could be zero, for example, we filled * the user buffer with data from the read-ahead buffers. And * 2) then we not want to wait if we already obtained some data from the * read-ahead buffer. In that case, return now with what we have (don't * want for more because there may be no timeout). + * 3) If however MSG_WAITALL flag is set, block here till all requested + * data are received (or there is a timeout / error). */ - if (state.ir_recvlen == 0 && state.ir_buflen > 0) + if (((flags & MSG_WAITALL) != 0 || state.ir_recvlen == 0) && + state.ir_buflen > 0) { /* Set up the callback in the connection */ state.ir_cb = tcp_callback_alloc(conn); if (state.ir_cb) { + int ret2; state.ir_cb->flags = (TCP_NEWDATA | TCP_DISCONN_EVENTS); + state.ir_cb->flags |= (flags & MSG_WAITALL) ? TCP_WAITALL : 0; state.ir_cb->priv = (FAR void *)&state; state.ir_cb->event = tcp_recvhandler; /* Wait for either the receive to complete or for an error/timeout - * to occur. net_timedwait will also terminate if a signal isi + * to occur. net_timedwait will also terminate if a signal is * received. */ - ret = net_timedwait(&state.ir_sem, - _SO_TIMEOUT(conn->sconn.s_rcvtimeo)); - if (ret == -ETIMEDOUT) + ret2 = net_timedwait(&state.ir_sem, Review Comment: Done. Maybe also remove `tcp_recvfrom_result()` altogether? The function now is very small and maybe it will be more readable to have the code directly within `psock_tcp_recvfrom()`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org