diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
commit | 29e6158507a0758192075ac6ece7ba8e75ddc49a (patch) | |
tree | b91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/peerstore | |
parent | 5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff) | |
download | gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.tar.gz gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.zip |
small API change: do no longer pass rarely needed GNUNET_SCHEDULER_TaskContext to all scheduler tasks; instead, allow the relatively few tasks that need it to obtain the context via GNUNET_SCHEDULER_get_task_context()
Diffstat (limited to 'src/peerstore')
-rw-r--r-- | src/peerstore/gnunet-peerstore.c | 6 | ||||
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 8 | ||||
-rw-r--r-- | src/peerstore/peerstore_api.c | 3 | ||||
-rw-r--r-- | src/peerstore/test_peerstore_api_sync.c | 28 |
4 files changed, 21 insertions, 24 deletions
diff --git a/src/peerstore/gnunet-peerstore.c b/src/peerstore/gnunet-peerstore.c index e274a1751..68ae1746f 100644 --- a/src/peerstore/gnunet-peerstore.c +++ b/src/peerstore/gnunet-peerstore.c | |||
@@ -32,16 +32,16 @@ static int ret; | |||
32 | /* | 32 | /* |
33 | * Handle to PEERSTORE service | 33 | * Handle to PEERSTORE service |
34 | */ | 34 | */ |
35 | struct GNUNET_PEERSTORE_Handle *peerstore_handle; | 35 | static struct GNUNET_PEERSTORE_Handle *peerstore_handle; |
36 | |||
36 | 37 | ||
37 | /** | 38 | /** |
38 | * Run on shutdown | 39 | * Run on shutdown |
39 | * | 40 | * |
40 | * @param cls unused | 41 | * @param cls unused |
41 | * @param tc scheduler context | ||
42 | */ | 42 | */ |
43 | static void | 43 | static void |
44 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 44 | shutdown_task (void *cls) |
45 | { | 45 | { |
46 | if (NULL != peerstore_handle) | 46 | if (NULL != peerstore_handle) |
47 | { | 47 | { |
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index f680c5d14..3a2d928e3 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -125,10 +125,9 @@ do_shutdown () | |||
125 | * Task run during shutdown. | 125 | * Task run during shutdown. |
126 | * | 126 | * |
127 | * @param cls unused | 127 | * @param cls unused |
128 | * @param tc unused | ||
129 | */ | 128 | */ |
130 | static void | 129 | static void |
131 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 130 | shutdown_task (void *cls) |
132 | { | 131 | { |
133 | in_shutdown = GNUNET_YES; | 132 | in_shutdown = GNUNET_YES; |
134 | if (NULL == client_head) /* Only when no connected clients. */ | 133 | if (NULL == client_head) /* Only when no connected clients. */ |
@@ -145,11 +144,12 @@ expire_records_continuation (void *cls, int success); | |||
145 | * Deletes any expired records from storage | 144 | * Deletes any expired records from storage |
146 | */ | 145 | */ |
147 | static void | 146 | static void |
148 | cleanup_expired_records (void *cls, | 147 | cleanup_expired_records (void *cls) |
149 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
150 | { | 148 | { |
151 | int ret; | 149 | int ret; |
150 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
152 | 151 | ||
152 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
153 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 153 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
154 | return; | 154 | return; |
155 | GNUNET_assert (NULL != db); | 155 | GNUNET_assert (NULL != db); |
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index a792f37ff..14117a333 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -358,10 +358,9 @@ rewatch_it (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
358 | * Called when the iterate request is timedout | 358 | * Called when the iterate request is timedout |
359 | * | 359 | * |
360 | * @param cls a `struct GNUNET_PEERSTORE_IterateContext *` | 360 | * @param cls a `struct GNUNET_PEERSTORE_IterateContext *` |
361 | * @param tc Scheduler task context (unused) | ||
362 | */ | 361 | */ |
363 | static void | 362 | static void |
364 | iterate_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 363 | iterate_timeout (void *cls) |
365 | { | 364 | { |
366 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; | 365 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; |
367 | GNUNET_PEERSTORE_Processor callback; | 366 | GNUNET_PEERSTORE_Processor callback; |
diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c index ad113a778..765ae9113 100644 --- a/src/peerstore/test_peerstore_api_sync.c +++ b/src/peerstore/test_peerstore_api_sync.c | |||
@@ -80,7 +80,7 @@ static const char *val = "test_peerstore_api_store_val"; | |||
80 | * @return #GNUNET_YES (all good, continue) | 80 | * @return #GNUNET_YES (all good, continue) |
81 | */ | 81 | */ |
82 | static int | 82 | static int |
83 | iterate_cb (void *cls, | 83 | iterate_cb (void *cls, |
84 | const struct GNUNET_PEERSTORE_Record *record, | 84 | const struct GNUNET_PEERSTORE_Record *record, |
85 | const char *emsg) | 85 | const char *emsg) |
86 | { | 86 | { |
@@ -89,7 +89,7 @@ iterate_cb (void *cls, | |||
89 | GNUNET_break (NULL == emsg); | 89 | GNUNET_break (NULL == emsg); |
90 | if (NULL == record) | 90 | if (NULL == record) |
91 | { | 91 | { |
92 | GNUNET_PEERSTORE_disconnect (h, | 92 | GNUNET_PEERSTORE_disconnect (h, |
93 | GNUNET_NO); | 93 | GNUNET_NO); |
94 | GNUNET_SCHEDULER_shutdown (); | 94 | GNUNET_SCHEDULER_shutdown (); |
95 | return GNUNET_YES; | 95 | return GNUNET_YES; |
@@ -106,17 +106,15 @@ iterate_cb (void *cls, | |||
106 | * data that should have been stored. | 106 | * data that should have been stored. |
107 | * | 107 | * |
108 | * @param cls NULL | 108 | * @param cls NULL |
109 | * @param tc unused | ||
110 | */ | 109 | */ |
111 | static void | 110 | static void |
112 | test_cont (void *cls, | 111 | test_cont (void *cls) |
113 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
114 | { | 112 | { |
115 | h = GNUNET_PEERSTORE_connect (cfg); | 113 | h = GNUNET_PEERSTORE_connect (cfg); |
116 | GNUNET_PEERSTORE_iterate (h, | 114 | GNUNET_PEERSTORE_iterate (h, |
117 | subsystem, | 115 | subsystem, |
118 | &pid, key, | 116 | &pid, key, |
119 | GNUNET_TIME_UNIT_FOREVER_REL, | 117 | GNUNET_TIME_UNIT_FOREVER_REL, |
120 | &iterate_cb, NULL); | 118 | &iterate_cb, NULL); |
121 | } | 119 | } |
122 | 120 | ||
@@ -128,15 +126,15 @@ static void | |||
128 | test1 () | 126 | test1 () |
129 | { | 127 | { |
130 | h = GNUNET_PEERSTORE_connect (cfg); | 128 | h = GNUNET_PEERSTORE_connect (cfg); |
131 | GNUNET_PEERSTORE_store (h, | 129 | GNUNET_PEERSTORE_store (h, |
132 | subsystem, | 130 | subsystem, |
133 | &pid, | 131 | &pid, |
134 | key, | 132 | key, |
135 | val, strlen (val) + 1, | 133 | val, strlen (val) + 1, |
136 | GNUNET_TIME_UNIT_FOREVER_ABS, | 134 | GNUNET_TIME_UNIT_FOREVER_ABS, |
137 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 135 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
138 | NULL, NULL); | 136 | NULL, NULL); |
139 | GNUNET_PEERSTORE_disconnect (h, | 137 | GNUNET_PEERSTORE_disconnect (h, |
140 | GNUNET_YES); | 138 | GNUNET_YES); |
141 | h = NULL; | 139 | h = NULL; |
142 | /* We need to wait a little bit to give the disconnect | 140 | /* We need to wait a little bit to give the disconnect |
@@ -158,7 +156,7 @@ test1 () | |||
158 | * @param peer handle to our peer (unused) | 156 | * @param peer handle to our peer (unused) |
159 | */ | 157 | */ |
160 | static void | 158 | static void |
161 | run (void *cls, | 159 | run (void *cls, |
162 | const struct GNUNET_CONFIGURATION_Handle *c, | 160 | const struct GNUNET_CONFIGURATION_Handle *c, |
163 | struct GNUNET_TESTING_Peer *peer) | 161 | struct GNUNET_TESTING_Peer *peer) |
164 | { | 162 | { |
@@ -173,7 +171,7 @@ int | |||
173 | main (int argc, char *argv[]) | 171 | main (int argc, char *argv[]) |
174 | { | 172 | { |
175 | if (0 != | 173 | if (0 != |
176 | GNUNET_TESTING_service_run ("test-gnunet-peerstore-sync", | 174 | GNUNET_TESTING_service_run ("test-gnunet-peerstore-sync", |
177 | "peerstore", | 175 | "peerstore", |
178 | "test_peerstore_api_data.conf", | 176 | "test_peerstore_api_data.conf", |
179 | &run, NULL)) | 177 | &run, NULL)) |