diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/fs/gnunet-service-fs_put.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/gnunet-service-fs_put.c')
-rw-r--r-- | src/fs/gnunet-service-fs_put.c | 176 |
1 files changed, 87 insertions, 89 deletions
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index 78a4b98df..deba91a0c 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.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 fs/gnunet-service-fs_put.c | 22 | * @file fs/gnunet-service-fs_put.c |
@@ -31,7 +31,7 @@ | |||
31 | /** | 31 | /** |
32 | * How often do we at most PUT content into the DHT? | 32 | * How often do we at most PUT content into the DHT? |
33 | */ | 33 | */ |
34 | #define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 34 | #define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * How many replicas do we try to create per PUT? | 37 | * How many replicas do we try to create per PUT? |
@@ -42,9 +42,7 @@ | |||
42 | /** | 42 | /** |
43 | * Context for each zero-anonymity iterator. | 43 | * Context for each zero-anonymity iterator. |
44 | */ | 44 | */ |
45 | struct PutOperator | 45 | struct PutOperator { |
46 | { | ||
47 | |||
48 | /** | 46 | /** |
49 | * Request to datastore for DHT PUTs (or NULL). | 47 | * Request to datastore for DHT PUTs (or NULL). |
50 | */ | 48 | */ |
@@ -88,8 +86,8 @@ struct PutOperator | |||
88 | * of block that we're putting into the DHT). | 86 | * of block that we're putting into the DHT). |
89 | */ | 87 | */ |
90 | static struct PutOperator operators[] = { | 88 | static struct PutOperator operators[] = { |
91 | {NULL, GNUNET_BLOCK_TYPE_FS_UBLOCK, 0, 0, 0}, | 89 | { NULL, GNUNET_BLOCK_TYPE_FS_UBLOCK, 0, 0, 0 }, |
92 | {NULL, GNUNET_BLOCK_TYPE_ANY, 0, 0, 0} | 90 | { NULL, GNUNET_BLOCK_TYPE_ANY, 0, 0, 0 } |
93 | }; | 91 | }; |
94 | 92 | ||
95 | 93 | ||
@@ -100,7 +98,7 @@ static struct PutOperator operators[] = { | |||
100 | * @param tc scheduler context (unused) | 98 | * @param tc scheduler context (unused) |
101 | */ | 99 | */ |
102 | static void | 100 | static void |
103 | gather_dht_put_blocks (void *cls); | 101 | gather_dht_put_blocks(void *cls); |
104 | 102 | ||
105 | 103 | ||
106 | /** | 104 | /** |
@@ -109,25 +107,25 @@ gather_dht_put_blocks (void *cls); | |||
109 | * @param po put operator to schedule | 107 | * @param po put operator to schedule |
110 | */ | 108 | */ |
111 | static void | 109 | static void |
112 | schedule_next_put (struct PutOperator *po) | 110 | schedule_next_put(struct PutOperator *po) |
113 | { | 111 | { |
114 | struct GNUNET_TIME_Relative delay; | 112 | struct GNUNET_TIME_Relative delay; |
115 | 113 | ||
116 | if (po->zero_anonymity_count_estimate > 0) | 114 | if (po->zero_anonymity_count_estimate > 0) |
117 | { | 115 | { |
118 | delay = | 116 | delay = |
119 | GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, | 117 | GNUNET_TIME_relative_divide(GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, |
120 | po->zero_anonymity_count_estimate); | 118 | po->zero_anonymity_count_estimate); |
121 | delay = GNUNET_TIME_relative_min (delay, MAX_DHT_PUT_FREQ); | 119 | delay = GNUNET_TIME_relative_min(delay, MAX_DHT_PUT_FREQ); |
122 | } | 120 | } |
123 | else | 121 | else |
124 | { | 122 | { |
125 | /* if we have NO zero-anonymity content yet, wait 5 minutes for some to | 123 | /* if we have NO zero-anonymity content yet, wait 5 minutes for some to |
126 | * (hopefully) appear */ | 124 | * (hopefully) appear */ |
127 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); | 125 | delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5); |
128 | } | 126 | } |
129 | po->dht_task = | 127 | po->dht_task = |
130 | GNUNET_SCHEDULER_add_delayed (delay, &gather_dht_put_blocks, po); | 128 | GNUNET_SCHEDULER_add_delayed(delay, &gather_dht_put_blocks, po); |
131 | } | 129 | } |
132 | 130 | ||
133 | 131 | ||
@@ -137,12 +135,12 @@ schedule_next_put (struct PutOperator *po) | |||
137 | * @param cls type of blocks to gather | 135 | * @param cls type of blocks to gather |
138 | */ | 136 | */ |
139 | static void | 137 | static void |
140 | delay_dht_put_blocks (void *cls) | 138 | delay_dht_put_blocks(void *cls) |
141 | { | 139 | { |
142 | struct PutOperator *po = cls; | 140 | struct PutOperator *po = cls; |
143 | 141 | ||
144 | po->dht_put = NULL; | 142 | po->dht_put = NULL; |
145 | schedule_next_put (po); | 143 | schedule_next_put(po); |
146 | } | 144 | } |
147 | 145 | ||
148 | 146 | ||
@@ -152,12 +150,12 @@ delay_dht_put_blocks (void *cls) | |||
152 | * @param cls type of blocks to gather | 150 | * @param cls type of blocks to gather |
153 | */ | 151 | */ |
154 | static void | 152 | static void |
155 | delay_dht_put_task (void *cls) | 153 | delay_dht_put_task(void *cls) |
156 | { | 154 | { |
157 | struct PutOperator *po = cls; | 155 | struct PutOperator *po = cls; |
158 | 156 | ||
159 | po->dht_task = NULL; | 157 | po->dht_task = NULL; |
160 | schedule_next_put (po); | 158 | schedule_next_put(po); |
161 | } | 159 | } |
162 | 160 | ||
163 | 161 | ||
@@ -177,45 +175,45 @@ delay_dht_put_task (void *cls) | |||
177 | * maybe 0 if no unique identifier is available | 175 | * maybe 0 if no unique identifier is available |
178 | */ | 176 | */ |
179 | static void | 177 | static void |
180 | process_dht_put_content (void *cls, | 178 | process_dht_put_content(void *cls, |
181 | const struct GNUNET_HashCode * key, | 179 | const struct GNUNET_HashCode * key, |
182 | size_t size, | 180 | size_t size, |
183 | const void *data, | 181 | const void *data, |
184 | enum GNUNET_BLOCK_Type type, | 182 | enum GNUNET_BLOCK_Type type, |
185 | uint32_t priority, | 183 | uint32_t priority, |
186 | uint32_t anonymity, | 184 | uint32_t anonymity, |
187 | uint32_t replication, | 185 | uint32_t replication, |
188 | struct GNUNET_TIME_Absolute expiration, | 186 | struct GNUNET_TIME_Absolute expiration, |
189 | uint64_t uid) | 187 | uint64_t uid) |
190 | { | 188 | { |
191 | struct PutOperator *po = cls; | 189 | struct PutOperator *po = cls; |
192 | 190 | ||
193 | po->dht_qe = NULL; | 191 | po->dht_qe = NULL; |
194 | if (key == NULL) | 192 | if (key == NULL) |
195 | { | 193 | { |
196 | po->zero_anonymity_count_estimate = po->result_count; | 194 | po->zero_anonymity_count_estimate = po->result_count; |
197 | po->result_count = 0; | 195 | po->result_count = 0; |
198 | po->next_uid = 0; | 196 | po->next_uid = 0; |
199 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 197 | po->dht_task = GNUNET_SCHEDULER_add_now(&delay_dht_put_task, po); |
200 | return; | 198 | return; |
201 | } | 199 | } |
202 | po->result_count++; | 200 | po->result_count++; |
203 | po->next_uid = uid + 1; | 201 | po->next_uid = uid + 1; |
204 | po->zero_anonymity_count_estimate = | 202 | po->zero_anonymity_count_estimate = |
205 | GNUNET_MAX (po->result_count, po->zero_anonymity_count_estimate); | 203 | GNUNET_MAX(po->result_count, po->zero_anonymity_count_estimate); |
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 204 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
207 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), | 205 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s(key), |
208 | type); | 206 | type); |
209 | po->dht_put = GNUNET_DHT_put (GSF_dht, | 207 | po->dht_put = GNUNET_DHT_put(GSF_dht, |
210 | key, | 208 | key, |
211 | DEFAULT_PUT_REPLICATION, | 209 | DEFAULT_PUT_REPLICATION, |
212 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 210 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
213 | type, | 211 | type, |
214 | size, | 212 | size, |
215 | data, | 213 | data, |
216 | expiration, | 214 | expiration, |
217 | &delay_dht_put_blocks, | 215 | &delay_dht_put_blocks, |
218 | po); | 216 | po); |
219 | } | 217 | } |
220 | 218 | ||
221 | 219 | ||
@@ -225,21 +223,21 @@ process_dht_put_content (void *cls, | |||
225 | * @param cls type of blocks to gather | 223 | * @param cls type of blocks to gather |
226 | */ | 224 | */ |
227 | static void | 225 | static void |
228 | gather_dht_put_blocks (void *cls) | 226 | gather_dht_put_blocks(void *cls) |
229 | { | 227 | { |
230 | struct PutOperator *po = cls; | 228 | struct PutOperator *po = cls; |
231 | 229 | ||
232 | po->dht_task = NULL; | 230 | po->dht_task = NULL; |
233 | po->dht_qe = | 231 | po->dht_qe = |
234 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, | 232 | GNUNET_DATASTORE_get_zero_anonymity(GSF_dsh, |
235 | po->next_uid, | 233 | po->next_uid, |
236 | 0, | 234 | 0, |
237 | UINT_MAX, | 235 | UINT_MAX, |
238 | po->dht_put_type, | 236 | po->dht_put_type, |
239 | &process_dht_put_content, | 237 | &process_dht_put_content, |
240 | po); | 238 | po); |
241 | if (NULL == po->dht_qe) | 239 | if (NULL == po->dht_qe) |
242 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 240 | po->dht_task = GNUNET_SCHEDULER_add_now(&delay_dht_put_task, po); |
243 | } | 241 | } |
244 | 242 | ||
245 | 243 | ||
@@ -247,17 +245,17 @@ gather_dht_put_blocks (void *cls) | |||
247 | * Setup the module. | 245 | * Setup the module. |
248 | */ | 246 | */ |
249 | void | 247 | void |
250 | GSF_put_init_ () | 248 | GSF_put_init_() |
251 | { | 249 | { |
252 | unsigned int i; | 250 | unsigned int i; |
253 | 251 | ||
254 | i = 0; | 252 | i = 0; |
255 | while (operators[i].dht_put_type != GNUNET_BLOCK_TYPE_ANY) | 253 | while (operators[i].dht_put_type != GNUNET_BLOCK_TYPE_ANY) |
256 | { | 254 | { |
257 | operators[i].dht_task = | 255 | operators[i].dht_task = |
258 | GNUNET_SCHEDULER_add_now (&gather_dht_put_blocks, &operators[i]); | 256 | GNUNET_SCHEDULER_add_now(&gather_dht_put_blocks, &operators[i]); |
259 | i++; | 257 | i++; |
260 | } | 258 | } |
261 | } | 259 | } |
262 | 260 | ||
263 | 261 | ||
@@ -265,31 +263,31 @@ GSF_put_init_ () | |||
265 | * Shutdown the module. | 263 | * Shutdown the module. |
266 | */ | 264 | */ |
267 | void | 265 | void |
268 | GSF_put_done_ () | 266 | GSF_put_done_() |
269 | { | 267 | { |
270 | struct PutOperator *po; | 268 | struct PutOperator *po; |
271 | unsigned int i; | 269 | unsigned int i; |
272 | 270 | ||
273 | i = 0; | 271 | i = 0; |
274 | while ((po = &operators[i])->dht_put_type != GNUNET_BLOCK_TYPE_ANY) | 272 | while ((po = &operators[i])->dht_put_type != GNUNET_BLOCK_TYPE_ANY) |
275 | { | ||
276 | if (NULL != po->dht_task) | ||
277 | { | ||
278 | GNUNET_SCHEDULER_cancel (po->dht_task); | ||
279 | po->dht_task = NULL; | ||
280 | } | ||
281 | if (NULL != po->dht_put) | ||
282 | { | ||
283 | GNUNET_DHT_put_cancel (po->dht_put); | ||
284 | po->dht_put = NULL; | ||
285 | } | ||
286 | if (NULL != po->dht_qe) | ||
287 | { | 273 | { |
288 | GNUNET_DATASTORE_cancel (po->dht_qe); | 274 | if (NULL != po->dht_task) |
289 | po->dht_qe = NULL; | 275 | { |
276 | GNUNET_SCHEDULER_cancel(po->dht_task); | ||
277 | po->dht_task = NULL; | ||
278 | } | ||
279 | if (NULL != po->dht_put) | ||
280 | { | ||
281 | GNUNET_DHT_put_cancel(po->dht_put); | ||
282 | po->dht_put = NULL; | ||
283 | } | ||
284 | if (NULL != po->dht_qe) | ||
285 | { | ||
286 | GNUNET_DATASTORE_cancel(po->dht_qe); | ||
287 | po->dht_qe = NULL; | ||
288 | } | ||
289 | i++; | ||
290 | } | 290 | } |
291 | i++; | ||
292 | } | ||
293 | } | 291 | } |
294 | 292 | ||
295 | /* end of gnunet-service-fs_put.c */ | 293 | /* end of gnunet-service-fs_put.c */ |