commit 0194245: [Minor] Add method ev_now_update_if_cheap

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Nov 1 12:35:15 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-11-01 12:32:14 +0000
URL: https://github.com/rspamd/rspamd/commit/0194245dcdbecfb34088339689668fd6c1111cb8

[Minor] Add method ev_now_update_if_cheap

---
 contrib/libev/ev.c | 8 ++++++++
 contrib/libev/ev.h | 5 +++++
 2 files changed, 13 insertions(+)

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)
@@ -3808,6 +3810,12 @@ ev_now_update (EV_P) EV_NOEXCEPT
   time_update (EV_A_ 1e100);
 }
 
+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
 {
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 */


More information about the Commits mailing list