aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-01 12:32:14 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-01 12:32:14 +0000
commit0194245dcdbecfb34088339689668fd6c1111cb8 (patch)
tree21468817181836fa83dfedf4349084377955dbfe
parentab2d0a0b1c89d22e970a7ddef3675d462ebb6b17 (diff)
downloadrspamd-0194245dcdbecfb34088339689668fd6c1111cb8.tar.gz
rspamd-0194245dcdbecfb34088339689668fd6c1111cb8.zip
[Minor] Add method ev_now_update_if_cheap
-rw-r--r--contrib/libev/ev.c8
-rw-r--r--contrib/libev/ev.h5
2 files changed, 13 insertions, 0 deletions
diff --git a/contrib/libev/ev.c b/contrib/libev/ev.c
index 38438e745..de32e1781 100644
--- a/contrib/libev/ev.c
+++ b/contrib/libev/ev.c
@@ -1572,6 +1572,7 @@ static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */
static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
static EV_ATOMIC_T monotinic_clock_id;
#endif
+static EV_ATOMIC_T have_cheap_timer = 0;
#ifndef EV_FD_TO_WIN32_HANDLE
# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd)
@@ -2898,6 +2899,7 @@ loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT
!clock_getres ((id), &ts)) { \
if (ts.tv_sec == 0 && ts.tv_nsec < 10ULL * 1000000) { \
monotinic_clock_id = (id); \
+ have_cheap_timer = 1; \
} \
} \
} while(0)
@@ -3809,6 +3811,12 @@ ev_now_update (EV_P) EV_NOEXCEPT
}
void
+ev_now_update_if_cheap (EV_P) EV_NOEXCEPT
+{
+ if (have_cheap_timer) time_update (EV_A_ 1e100);
+}
+
+void
ev_suspend (EV_P) EV_NOEXCEPT
{
ev_now_update (EV_A);
diff --git a/contrib/libev/ev.h b/contrib/libev/ev.h
index 4b7503d3d..9d3e4f2fd 100644
--- a/contrib/libev/ev.h
+++ b/contrib/libev/ev.h
@@ -596,6 +596,11 @@ EV_API_DECL void ev_loop_fork (EV_P) EV_NOEXCEPT;
EV_API_DECL unsigned int ev_backend (EV_P) EV_NOEXCEPT; /* backend in use by loop */
EV_API_DECL void ev_now_update (EV_P) EV_NOEXCEPT; /* update event loop time */
+/*
+ * Same as ev_now_update, but will update time merely if cheap (coarse) timers
+ * are used in system.
+ */
+EV_API_DECL void ev_now_update_if_cheap (EV_P) EV_NOEXCEPT;
#if EV_WALK_ENABLE
/* walk (almost) all watchers in the loop of a given type, invoking the */