[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16166 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16166 - gnunet/src/util |
Date: |
Mon, 25 Jul 2011 14:36:16 +0200 |
Author: nevans
Date: 2011-07-25 14:36:16 +0200 (Mon, 25 Jul 2011)
New Revision: 16166
Modified:
gnunet/src/util/program.c
gnunet/src/util/server.c
gnunet/src/util/service.c
gnunet/src/util/time.c
Log:
clockskew code
Modified: gnunet/src/util/program.c
===================================================================
--- gnunet/src/util/program.c 2011-07-25 12:35:33 UTC (rev 16165)
+++ gnunet/src/util/program.c 2011-07-25 12:36:16 UTC (rev 16166)
@@ -134,6 +134,9 @@
char *logfile;
int ret;
unsigned int cnt;
+ unsigned long long skew_offset;
+ unsigned long long skew_variance;
+ long long clock_offset;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_GETOPT_CommandLineOption defoptions[] = {
GNUNET_GETOPT_OPTION_CFG_FILE (&cc.cfgfile),
@@ -229,7 +232,11 @@
}
GNUNET_free (allopts);
GNUNET_free (lpfx);
-
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cc.cfg, "testing",
"skew_offset", &skew_offset) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cc.cfg, "testing",
"skew_variance", &skew_variance)))
+ {
+ clock_offset = skew_offset - skew_variance;
+ }
/* run */
cc.args = &argv[ret];
GNUNET_SCHEDULER_run (&program_main, &cc);
Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c 2011-07-25 12:35:33 UTC (rev 16165)
+++ gnunet/src/util/server.c 2011-07-25 12:36:16 UTC (rev 16166)
@@ -1014,8 +1014,8 @@
* @param timeout new timeout for activities on the socket
*/
void
-GNUNET_SERVER_client_set_timeout (struct GNUNET_SERVER_Client *client,
- struct GNUNET_TIME_Relative timeout)
+GNUNET_SERVER_client_set_timeout(struct GNUNET_SERVER_Client *client,
+ struct GNUNET_TIME_Relative timeout)
{
client->idle_timeout = timeout;
}
Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c 2011-07-25 12:35:33 UTC (rev 16165)
+++ gnunet/src/util/service.c 2011-07-25 12:36:16 UTC (rev 16166)
@@ -1577,6 +1577,9 @@
char *logfile;
int do_daemonize;
unsigned int i;
+ unsigned long long skew_offset;
+ unsigned long long skew_variance;
+ long long clock_offset;
struct GNUNET_SERVICE_Context sctx;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_GETOPT_CommandLineOption service_options[] = {
@@ -1623,6 +1626,14 @@
"Service `%s' runs with configuration from `%s'\n",
serviceName, cfg_fn);
#endif
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(sctx.cfg, "testing",
"skew_offset", &skew_offset) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(sctx.cfg, "testing",
"skew_variance", &skew_variance)))
+ {
+ clock_offset = skew_offset - skew_variance;
+#if 1
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skewing clock by %ll\n",
clock_offset);
+#endif
+ }
/* actually run service */
GNUNET_SCHEDULER_run (&service_task, &sctx);
Modified: gnunet/src/util/time.c
===================================================================
--- gnunet/src/util/time.c 2011-07-25 12:35:33 UTC (rev 16165)
+++ gnunet/src/util/time.c 2011-07-25 12:36:16 UTC (rev 16166)
@@ -26,8 +26,20 @@
#include "platform.h"
#include "gnunet_time_lib.h"
+static long long timestamp_offset;
/**
+ * Set the timestamp offset for this instance.
+ *
+ * @param offset the offset to skew the locale time by
+ */
+void
+GNUNET_TIME_set_offset(long long offset)
+{
+ timestamp_offset = offset;
+}
+
+/**
* Get the current time (works just as "time", just that we use the
* unit of time that the cron-jobs use (and is 64 bit)).
*
@@ -42,7 +54,7 @@
GETTIMEOFDAY (&tv, NULL);
ret.abs_value =
(uint64_t) (((uint64_t) tv.tv_sec * 1000LL) +
- ((uint64_t) tv.tv_usec / 1000LL));
+ ((uint64_t) tv.tv_usec / 1000LL)) + timestamp_offset;
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16166 - gnunet/src/util,
gnunet <=