summaryrefslogtreecommitdiff
path: root/ctdb/lib
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2010-09-28 08:58:03 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2010-09-28 08:59:35 +1000
commit869242a7cdef1169fc310efea1624ec6e134ad19 (patch)
tree9234eb84c3c0cd1ccb92b23380cb339bd5dc7fe2 /ctdb/lib
parent107d020cfafe8473ac9d525fecd4eb777e7956c1 (diff)
downloadsamba-869242a7cdef1169fc310efea1624ec6e134ad19.tar.gz
Add back monitoring for time skips, forward as well as backward.
This serviceability tool was lost during the migration from the old eventsystem to the tevent system. (This used to be ctdb commit b4c00b4ac30ec215629f44f802ce9660abcd7a48)
Diffstat (limited to 'ctdb/lib')
-rw-r--r--ctdb/lib/tevent/tevent.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ctdb/lib/tevent/tevent.c b/ctdb/lib/tevent/tevent.c
index 8cc9ce5203c..2f6e591baad 100644
--- a/ctdb/lib/tevent/tevent.c
+++ b/ctdb/lib/tevent/tevent.c
@@ -64,6 +64,9 @@
#include "tevent_internal.h"
#include "tevent_util.h"
+/* needed for the special ctdbd "track if time jumps unexpectedly */
+#include <time.h>
+
struct tevent_ops_list {
struct tevent_ops_list *next, *prev;
const char *name;
@@ -578,12 +581,18 @@ done:
return ret;
}
+
+extern pid_t ctdbd_pid;
+
/*
return on failure or (with 0) if all fd events are removed
*/
int tevent_common_loop_wait(struct tevent_context *ev,
const char *location)
{
+ static time_t t=0;
+ time_t new_t;
+
/*
* loop as long as we have events pending
*/
@@ -599,6 +608,19 @@ int tevent_common_loop_wait(struct tevent_context *ev,
ret, strerror(errno));
return ret;
}
+ if (getpid() == ctdbd_pid) {
+ new_t=time(NULL);
+ if (t != 0) {
+ if (t > new_t) {
+ tevent_debug(ev, TEVENT_DEBUG_FATAL, __location__ " ERROR Time skipped backward by %d seconds\n", (int)(t-new_t));
+ }
+ /* We assume here that we get at least one event every 3 seconds */
+ if (new_t > (t+3)) {
+ tevent_debug(ev, TEVENT_DEBUG_FATAL, __location__ " ERROR Time jumped forward by %d seconds\n", (int)(new_t-t));
+ }
+ }
+ t=new_t;
+ }
}
tevent_debug(ev, TEVENT_DEBUG_WARNING,