diff options
Diffstat (limited to 'src/util/speedup.c')
-rw-r--r-- | src/util/speedup.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/util/speedup.c b/src/util/speedup.c index c5c1f6a53..735da18c3 100644 --- a/src/util/speedup.c +++ b/src/util/speedup.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file util/speedup.c | 22 | * @file util/speedup.c |
@@ -27,7 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "speedup.h" | 28 | #include "speedup.h" |
29 | 29 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "util-speedup", __VA_ARGS__) | 30 | #define LOG(kind, ...) GNUNET_log_from(kind, "util-speedup", __VA_ARGS__) |
31 | 31 | ||
32 | 32 | ||
33 | static struct GNUNET_TIME_Relative interval; | 33 | static struct GNUNET_TIME_Relative interval; |
@@ -38,20 +38,20 @@ static struct GNUNET_SCHEDULER_Task *speedup_task; | |||
38 | 38 | ||
39 | 39 | ||
40 | static void | 40 | static void |
41 | do_speedup (void *cls) | 41 | do_speedup(void *cls) |
42 | { | 42 | { |
43 | static long long current_offset; | 43 | static long long current_offset; |
44 | 44 | ||
45 | (void) cls; | 45 | (void)cls; |
46 | speedup_task = NULL; | 46 | speedup_task = NULL; |
47 | current_offset += delta.rel_value_us; | 47 | current_offset += delta.rel_value_us; |
48 | GNUNET_TIME_set_offset (current_offset); | 48 | GNUNET_TIME_set_offset(current_offset); |
49 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 49 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
50 | "Speeding up execution time by %s\n", | 50 | "Speeding up execution time by %s\n", |
51 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO)); | 51 | GNUNET_STRINGS_relative_time_to_string(delta, GNUNET_NO)); |
52 | speedup_task = GNUNET_SCHEDULER_add_delayed (interval, | 52 | speedup_task = GNUNET_SCHEDULER_add_delayed(interval, |
53 | &do_speedup, | 53 | &do_speedup, |
54 | NULL); | 54 | NULL); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
@@ -62,38 +62,38 @@ do_speedup (void *cls) | |||
62 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the speedup was not configured | 62 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the speedup was not configured |
63 | */ | 63 | */ |
64 | int | 64 | int |
65 | GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg) | 65 | GNUNET_SPEEDUP_start_(const struct GNUNET_CONFIGURATION_Handle *cfg) |
66 | { | 66 | { |
67 | GNUNET_assert (NULL == speedup_task); | 67 | GNUNET_assert(NULL == speedup_task); |
68 | if (GNUNET_OK != | 68 | if (GNUNET_OK != |
69 | GNUNET_CONFIGURATION_get_value_time (cfg, | 69 | GNUNET_CONFIGURATION_get_value_time(cfg, |
70 | "testing", | 70 | "testing", |
71 | "SPEEDUP_INTERVAL", | 71 | "SPEEDUP_INTERVAL", |
72 | &interval)) | 72 | &interval)) |
73 | return GNUNET_SYSERR; | 73 | return GNUNET_SYSERR; |
74 | if (GNUNET_OK != | 74 | if (GNUNET_OK != |
75 | GNUNET_CONFIGURATION_get_value_time (cfg, | 75 | GNUNET_CONFIGURATION_get_value_time(cfg, |
76 | "testing", | 76 | "testing", |
77 | "SPEEDUP_DELTA", | 77 | "SPEEDUP_DELTA", |
78 | &delta)) | 78 | &delta)) |
79 | return GNUNET_SYSERR; | 79 | return GNUNET_SYSERR; |
80 | 80 | ||
81 | if ( (0 == interval.rel_value_us) || | 81 | if ((0 == interval.rel_value_us) || |
82 | (0 == delta.rel_value_us) ) | 82 | (0 == delta.rel_value_us)) |
83 | { | 83 | { |
84 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 84 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
85 | "Speed up disabled\n"); | 85 | "Speed up disabled\n"); |
86 | return GNUNET_OK; | 86 | return GNUNET_OK; |
87 | } | 87 | } |
88 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 88 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
89 | "Speed up execution by %s\n", | 89 | "Speed up execution by %s\n", |
90 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO)); | 90 | GNUNET_STRINGS_relative_time_to_string(delta, GNUNET_NO)); |
91 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 91 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
92 | "Speed up executed every %s\n", | 92 | "Speed up executed every %s\n", |
93 | GNUNET_STRINGS_relative_time_to_string (interval, GNUNET_NO)); | 93 | GNUNET_STRINGS_relative_time_to_string(interval, GNUNET_NO)); |
94 | speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, | 94 | speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness(GNUNET_NO, |
95 | &do_speedup, | 95 | &do_speedup, |
96 | NULL); | 96 | NULL); |
97 | return GNUNET_OK; | 97 | return GNUNET_OK; |
98 | } | 98 | } |
99 | 99 | ||
@@ -102,17 +102,17 @@ GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
102 | * Stop tasks that modify clock behavior. | 102 | * Stop tasks that modify clock behavior. |
103 | */ | 103 | */ |
104 | void | 104 | void |
105 | GNUNET_SPEEDUP_stop_ () | 105 | GNUNET_SPEEDUP_stop_() |
106 | { | 106 | { |
107 | if (NULL != speedup_task) | 107 | if (NULL != speedup_task) |
108 | { | 108 | { |
109 | GNUNET_SCHEDULER_cancel (speedup_task); | 109 | GNUNET_SCHEDULER_cancel(speedup_task); |
110 | speedup_task = NULL; | 110 | speedup_task = NULL; |
111 | } | 111 | } |
112 | if ( (0 != interval.rel_value_us) && | 112 | if ((0 != interval.rel_value_us) && |
113 | (0 != delta.rel_value_us) ) | 113 | (0 != delta.rel_value_us)) |
114 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 114 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
115 | "Stopped execution speed up\n"); | 115 | "Stopped execution speed up\n"); |
116 | } | 116 | } |
117 | 117 | ||
118 | /* end of speedup.c */ | 118 | /* end of speedup.c */ |