1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

patch the event loop so we read the current time every iteration.

log an error if the clock jumps backwards
also log an error if the clock jumps >5 seconds forward (we assume here we will get at least one event every 5 seconds)

(This used to be ctdb commit 11193e1e192bee6f579bdf1303153571a82711d7)
This commit is contained in:
Ronnie Sahlberg 2009-10-26 13:20:35 +11:00
parent 8aacfa348d
commit 299b027b8c
3 changed files with 42 additions and 0 deletions

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "system/time.h"
#include "system/filesys.h"
#include "system/network.h"
#include "lib/util/dlinklist.h"
@ -457,12 +458,25 @@ static int epoll_event_loop_once(struct event_context *ev)
*/
static int epoll_event_loop_wait(struct event_context *ev)
{
static time_t t=0;
time_t new_t;
struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
struct epoll_event_context);
while (epoll_ev->num_fd_events) {
if (epoll_event_loop_once(ev) != 0) {
break;
}
new_t=time(NULL);
if (t != 0) {
if (t > new_t) {
DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
}
/* We assume here that we get at least one event every 5 seconds */
if (new_t > (t+5)) {
DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
}
}
t=new_t;
}
return 0;

View File

@ -24,6 +24,7 @@
*/
#include "includes.h"
#include "system/time.h"
#include "system/filesys.h"
#include "system/select.h"
#include "lib/util/dlinklist.h"
@ -270,6 +271,8 @@ static int select_event_loop_once(struct event_context *ev)
*/
static int select_event_loop_wait(struct event_context *ev)
{
static time_t t=0;
time_t new_t;
struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
struct select_event_context);
select_ev->exit_code = 0;
@ -278,6 +281,17 @@ static int select_event_loop_wait(struct event_context *ev)
if (select_event_loop_once(ev) != 0) {
break;
}
new_t=time(NULL);
if (t != 0) {
if (t > new_t) {
DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
}
/* We assume here that we get at least one event every 5 seconds */
if (new_t > (t+5)) {
DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
}
}
t=new_t;
}
return select_ev->exit_code;

View File

@ -28,6 +28,7 @@
*/
#include "includes.h"
#include "system/time.h"
#include "system/filesys.h"
#include "system/network.h"
#include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */
@ -571,6 +572,8 @@ static int std_event_loop_once(struct event_context *ev)
*/
static int std_event_loop_wait(struct event_context *ev)
{
static time_t t=0;
time_t new_t;
struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
struct std_event_context);
std_ev->exit_code = 0;
@ -579,6 +582,17 @@ static int std_event_loop_wait(struct event_context *ev)
if (std_event_loop_once(ev) != 0) {
break;
}
new_t=time(NULL);
if (t != 0) {
if (t > new_t) {
DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
}
/* We assume here that we get at least one event every 5 seconds */
if (new_t > (t+5)) {
DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
}
}
t=new_t;
}
return std_ev->exit_code;