pkarashchenko commented on a change in pull request #5526: URL: https://github.com/apache/incubator-nuttx/pull/5526#discussion_r808809882
########## File path: net/tcp/tcp_send_buffered.c ########## @@ -1108,6 +1117,15 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, nonblock = _SS_ISNONBLOCK(conn->sconn.s_flags) || (flags & MSG_DONTWAIT) != 0; + expire = _SO_TIMEOUT(conn->sconn.s_sndtimeo); + if (expire != UINT_MAX) + { + expire += TICK2MSEC(clock_systime_ticks()); + if (expire == UINT_MAX) + { + expire--; Review comment: why `--` and not `++`? ########## File path: net/tcp/tcp_send_buffered.c ########## @@ -1172,7 +1190,25 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, goto errout_with_lock; } - net_lockedwait_uninterruptible(&conn->snd_sem); + current = TICK2MSEC(clock_systime_ticks()); + if (expire == UINT_MAX) + { + remain = UINT_MAX; + } + else if (expire > current) + { + remain = expire - current; + } + else + { + remain = 0; + } + + ret = net_timedwait_uninterruptible(&conn->snd_sem, remain); Review comment: shouldn't this be wrapped with `if (remain > 0)`? ########## File path: net/tcp/tcp_send_buffered.c ########## @@ -1172,7 +1190,25 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, goto errout_with_lock; } - net_lockedwait_uninterruptible(&conn->snd_sem); + current = TICK2MSEC(clock_systime_ticks()); + if (expire == UINT_MAX) + { + remain = UINT_MAX; + } + else if (expire > current) + { + remain = expire - current; + } + else + { + remain = 0; Review comment: Shouldn't we have here ```suggestion remain = current - expire; ``` ? ########## File path: net/tcp/tcp_send_buffered.c ########## @@ -1053,6 +1053,15 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, ssize_t result = 0; bool nonblock; int ret = OK; +#ifdef CONFIG_HAVE_LONG_LONG + uint64_t expire; + uint64_t remain; + uint64_t current; +#else + clock_t expire; + clock_t remain; + clock_t current; +#endif Review comment: ```suggestion unsigned int expire; unsigned int remain; unsigned int current; ``` -- 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