|
|
@@ -2946,6 +2946,42 @@ void notifier_read(notifier_t fd)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+bool notifier_wait(notifier_t notifier, const struct timeval *tvp_timeout)
|
|
|
+{
|
|
|
+ struct timeval tv_now, tv_timeout;
|
|
|
+ fd_set rfds;
|
|
|
+ int e;
|
|
|
+
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ FD_ZERO(&rfds);
|
|
|
+ FD_SET(notifier[0], &rfds);
|
|
|
+ tv_timeout = *tvp_timeout;
|
|
|
+ timer_set_now(&tv_now);
|
|
|
+ e = select(notifier[0]+1, &rfds, NULL, NULL, select_timeout(&tv_timeout, &tv_now));
|
|
|
+ if (e > 0)
|
|
|
+ return true;
|
|
|
+ if (e == 0)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool notifier_wait_us(notifier_t notifier, const unsigned long long usecs)
|
|
|
+{
|
|
|
+ struct timeval tv_timeout = TIMEVAL_USECS(usecs);
|
|
|
+ return notifier_wait(notifier, &tv_timeout);
|
|
|
+}
|
|
|
+
|
|
|
+void notifier_reset(notifier_t notifier)
|
|
|
+{
|
|
|
+ fd_set rfds;
|
|
|
+ struct timeval tv_timeout = { .tv_sec = 0, };
|
|
|
+ FD_ZERO(&rfds);
|
|
|
+ FD_SET(notifier[0], &rfds);
|
|
|
+ while (select(notifier[0]+1, &rfds, NULL, NULL, &tv_timeout) != 0)
|
|
|
+ notifier_read(notifier);
|
|
|
+}
|
|
|
+
|
|
|
void notifier_init_invalid(notifier_t fd)
|
|
|
{
|
|
|
fd[0] = fd[1] = INVSOCK;
|