diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-27 15:49:02 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-27 15:49:02 +0000 |
commit | 07ba70f731218eb74993553ff4923fd2ece3635b (patch) | |
tree | 4f4c1ec11eac116ef90927f6dcc686a7c3253fc5 /src | |
parent | 95daec0a418692408dadb9d0071b717295dde047 (diff) | |
download | gnunet-07ba70f731218eb74993553ff4923fd2ece3635b.tar.gz gnunet-07ba70f731218eb74993553ff4923fd2ece3635b.zip |
use arm timeouts, bad GNUNET_TIME function that will probably get removed
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_time_lib.h | 11 | ||||
-rw-r--r-- | src/testing/testing.c | 12 | ||||
-rw-r--r-- | src/util/time.c | 19 |
3 files changed, 41 insertions, 1 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index b1ffc4d40..386f6d609 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -422,6 +422,17 @@ struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh (struct | |||
422 | a); | 422 | a); |
423 | 423 | ||
424 | /** | 424 | /** |
425 | * Convert a relative time to a string. | ||
426 | * NOT reentrant! | ||
427 | * | ||
428 | * @param time the time to print | ||
429 | * | ||
430 | * @return string form of the time (as milliseconds) | ||
431 | */ | ||
432 | const char * | ||
433 | GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time); | ||
434 | |||
435 | /** | ||
425 | * Set the timestamp offset for this instance. | 436 | * Set the timestamp offset for this instance. |
426 | * | 437 | * |
427 | * @param offset the offset to skew the locale time by | 438 | * @param offset the offset to skew the locale time by |
diff --git a/src/testing/testing.c b/src/testing/testing.c index a079390ad..a9734aea6 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -576,7 +576,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
576 | #if DEBUG_TESTING | 576 | #if DEBUG_TESTING |
577 | "-L", "DEBUG", | 577 | "-L", "DEBUG", |
578 | #endif | 578 | #endif |
579 | "-s", "-q", NULL); | 579 | "-s", "-q", "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), NULL); |
580 | } | 580 | } |
581 | else | 581 | else |
582 | { | 582 | { |
@@ -602,6 +602,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
602 | "-L", "DEBUG", | 602 | "-L", "DEBUG", |
603 | #endif | 603 | #endif |
604 | "-c", d->cfgfile, "-s", "-q", | 604 | "-c", d->cfgfile, "-s", "-q", |
605 | "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), | ||
605 | NULL); | 606 | NULL); |
606 | } | 607 | } |
607 | else | 608 | else |
@@ -617,6 +618,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
617 | "-L", "DEBUG", | 618 | "-L", "DEBUG", |
618 | #endif | 619 | #endif |
619 | "-c", d->cfgfile, "-s", "-q", | 620 | "-c", d->cfgfile, "-s", "-q", |
621 | "-T", GNUNET_TIME_relative_to_string(GNUNET_TIME_absolute_get_remaining(d->max_timeout)), | ||
620 | NULL); | 622 | NULL); |
621 | } | 623 | } |
622 | GNUNET_free (dst); | 624 | GNUNET_free (dst); |
@@ -1101,6 +1103,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1101 | "-L", "DEBUG", | 1103 | "-L", "DEBUG", |
1102 | #endif | 1104 | #endif |
1103 | "-c", d->cfgfile, "-i", service, "-q", | 1105 | "-c", d->cfgfile, "-i", service, "-q", |
1106 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1104 | NULL); | 1107 | NULL); |
1105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1106 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", | 1109 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", |
@@ -1120,6 +1123,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1120 | "-L", "DEBUG", | 1123 | "-L", "DEBUG", |
1121 | #endif | 1124 | #endif |
1122 | "-c", d->cfgfile, "-i", service, "-q", | 1125 | "-c", d->cfgfile, "-i", service, "-q", |
1126 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1123 | NULL); | 1127 | NULL); |
1124 | } | 1128 | } |
1125 | 1129 | ||
@@ -1180,6 +1184,7 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, | |||
1180 | "-L", "DEBUG", | 1184 | "-L", "DEBUG", |
1181 | #endif | 1185 | #endif |
1182 | "-c", d->cfgfile, "-i", service, "-q", | 1186 | "-c", d->cfgfile, "-i", service, "-q", |
1187 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1183 | NULL); | 1188 | NULL); |
1184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1185 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", | 1190 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", |
@@ -1199,6 +1204,7 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, | |||
1199 | "-L", "DEBUG", | 1204 | "-L", "DEBUG", |
1200 | #endif | 1205 | #endif |
1201 | "-c", d->cfgfile, "-i", service, "-q", | 1206 | "-c", d->cfgfile, "-i", service, "-q", |
1207 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1202 | NULL); | 1208 | NULL); |
1203 | } | 1209 | } |
1204 | 1210 | ||
@@ -1644,6 +1650,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, | |||
1644 | "-L", "DEBUG", | 1650 | "-L", "DEBUG", |
1645 | #endif | 1651 | #endif |
1646 | "-c", d->cfgfile, "-k", service, "-q", | 1652 | "-c", d->cfgfile, "-k", service, "-q", |
1653 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1647 | NULL); | 1654 | NULL); |
1648 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1649 | "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -k %s -q\n", | 1656 | "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -k %s -q\n", |
@@ -1663,6 +1670,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, | |||
1663 | "-L", "DEBUG", | 1670 | "-L", "DEBUG", |
1664 | #endif | 1671 | #endif |
1665 | "-c", d->cfgfile, "-k", service, "-q", | 1672 | "-c", d->cfgfile, "-k", service, "-q", |
1673 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1666 | NULL); | 1674 | NULL); |
1667 | } | 1675 | } |
1668 | 1676 | ||
@@ -1781,6 +1789,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
1781 | "-L", "DEBUG", | 1789 | "-L", "DEBUG", |
1782 | #endif | 1790 | #endif |
1783 | "-c", d->cfgfile, "-e", "-q", | 1791 | "-c", d->cfgfile, "-e", "-q", |
1792 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1784 | del_arg, NULL); | 1793 | del_arg, NULL); |
1785 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1786 | "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -e -q %s\n", | 1795 | "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s -e -q %s\n", |
@@ -1801,6 +1810,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
1801 | "-L", "DEBUG", | 1810 | "-L", "DEBUG", |
1802 | #endif | 1811 | #endif |
1803 | "-c", d->cfgfile, "-e", "-q", | 1812 | "-c", d->cfgfile, "-e", "-q", |
1813 | "-T", GNUNET_TIME_relative_to_string(timeout), | ||
1804 | del_arg, NULL); | 1814 | del_arg, NULL); |
1805 | } | 1815 | } |
1806 | 1816 | ||
diff --git a/src/util/time.c b/src/util/time.c index 5ae05b0d7..3631c0a78 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -486,6 +486,25 @@ GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) | |||
486 | 486 | ||
487 | } | 487 | } |
488 | 488 | ||
489 | /** | ||
490 | * Convert a relative time to a string. | ||
491 | * This is one of the very few calls in the entire API that is | ||
492 | * NOT reentrant! | ||
493 | * | ||
494 | * @param time the time to print | ||
495 | * | ||
496 | * @return string form of the time (as milliseconds) | ||
497 | */ | ||
498 | const char * | ||
499 | GNUNET_TIME_relative_to_string (struct GNUNET_TIME_Relative time) | ||
500 | { | ||
501 | static char time_string[21]; | ||
502 | memset(time_string, 0, sizeof(time_string)); | ||
503 | |||
504 | sprintf(time_string, "%lu", time.rel_value); | ||
505 | return (const char *) time_string; | ||
506 | } | ||
507 | |||
489 | 508 | ||
490 | 509 | ||
491 | /* end of time.c */ | 510 | /* end of time.c */ |