mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
If select() is only used for sleep, convert it to nanosleep,
it only need purely wait in user space.
This commit is contained in:
parent
e921a3c976
commit
f399623004
2 changed files with 18 additions and 8 deletions
|
|
@ -50,11 +50,16 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
struct timeval *timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
_thr_enter_cancellation_point(curthread);
|
||||
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
|
||||
_thr_leave_cancellation_point(curthread);
|
||||
|
||||
if (numfds == 0 && timeout != NULL) {
|
||||
TIMEVAL_TO_TIMESPEC(timeout, &ts);
|
||||
return nanosleep(&ts, NULL);
|
||||
} else {
|
||||
_thr_enter_cancellation_point(curthread);
|
||||
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
|
||||
_thr_leave_cancellation_point(curthread);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,16 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|||
struct timeval *timeout)
|
||||
{
|
||||
struct pthread *curthread = _get_curthread();
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
_thr_enter_cancellation_point(curthread);
|
||||
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
|
||||
_thr_leave_cancellation_point(curthread);
|
||||
|
||||
if (numfds == 0 && timeout != NULL) {
|
||||
TIMEVAL_TO_TIMESPEC(timeout, &ts);
|
||||
return nanosleep(&ts, NULL);
|
||||
} else {
|
||||
_thr_enter_cancellation_point(curthread);
|
||||
ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);
|
||||
_thr_leave_cancellation_point(curthread);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue