pkarashchenko commented on a change in pull request #5526: URL: https://github.com/apache/incubator-nuttx/pull/5526#discussion_r808877388
########## 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: ``` static int _net_timedwait(sem_t *sem, bool interruptible, unsigned int timeout) { unsigned int count; irqstate_t flags; int blresult; int ret; flags = enter_critical_section(); /* No interrupts */ sched_lock(); /* No context switches */ /* Release the network lock, remembering my count. net_breaklock will * return a negated value if the caller does not hold the network lock. */ blresult = net_breaklock(&count); /* Now take the semaphore, waiting if so requested. */ if (timeout != UINT_MAX) { struct timespec abstime; DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime)); abstime.tv_sec += timeout / MSEC_PER_SEC; abstime.tv_nsec += timeout % MSEC_PER_SEC * NSEC_PER_MSEC; if (abstime.tv_nsec >= NSEC_PER_SEC) { abstime.tv_sec++; abstime.tv_nsec -= NSEC_PER_SEC; } /* Wait until we get the lock or until the timeout expires */ if (interruptible) { ret = nxsem_timedwait(sem, &abstime); } else { ret = nxsem_timedwait_uninterruptible(sem, &abstime); } } else { /* Wait as long as necessary to get the lock */ if (interruptible) { ret = nxsem_wait(sem); } else { ret = nxsem_wait_uninterruptible(sem); } } /* Recover the network lock at the proper count (if we held it before) */ if (blresult >= 0) { net_restorelock(count); } sched_unlock(); leave_critical_section(flags); return ret; } ``` No trywait in case if `timeout == 0`. -- 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