diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_cadet_server.c')
-rw-r--r-- | src/fs/gnunet-service-fs_cadet_server.c | 457 |
1 files changed, 227 insertions, 230 deletions
diff --git a/src/fs/gnunet-service-fs_cadet_server.c b/src/fs/gnunet-service-fs_cadet_server.c index bb320806a..68e87f092 100644 --- a/src/fs/gnunet-service-fs_cadet_server.c +++ b/src/fs/gnunet-service-fs_cadet_server.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_cadet_server.c | 22 | * @file fs/gnunet-service-fs_cadet_server.c |
@@ -40,14 +40,13 @@ | |||
40 | /** | 40 | /** |
41 | * After how long do we termiante idle connections? | 41 | * After how long do we termiante idle connections? |
42 | */ | 42 | */ |
43 | #define IDLE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) | 43 | #define IDLE_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) |
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
47 | * A message in the queue to be written to the cadet. | 47 | * A message in the queue to be written to the cadet. |
48 | */ | 48 | */ |
49 | struct WriteQueueItem | 49 | struct WriteQueueItem { |
50 | { | ||
51 | /** | 50 | /** |
52 | * Kept in a DLL. | 51 | * Kept in a DLL. |
53 | */ | 52 | */ |
@@ -68,8 +67,7 @@ struct WriteQueueItem | |||
68 | /** | 67 | /** |
69 | * Information we keep around for each active cadeting client. | 68 | * Information we keep around for each active cadeting client. |
70 | */ | 69 | */ |
71 | struct CadetClient | 70 | struct CadetClient { |
72 | { | ||
73 | /** | 71 | /** |
74 | * DLL | 72 | * DLL |
75 | */ | 73 | */ |
@@ -114,7 +112,6 @@ struct CadetClient | |||
114 | * Size of the last write that was initiated. | 112 | * Size of the last write that was initiated. |
115 | */ | 113 | */ |
116 | size_t reply_size; | 114 | size_t reply_size; |
117 | |||
118 | }; | 115 | }; |
119 | 116 | ||
120 | 117 | ||
@@ -151,7 +148,7 @@ static unsigned long long sc_count_max; | |||
151 | * @param cls the 'struct CadetClient' | 148 | * @param cls the 'struct CadetClient' |
152 | */ | 149 | */ |
153 | static void | 150 | static void |
154 | timeout_cadet_task (void *cls) | 151 | timeout_cadet_task(void *cls) |
155 | { | 152 | { |
156 | struct CadetClient *sc = cls; | 153 | struct CadetClient *sc = cls; |
157 | struct GNUNET_CADET_Channel *tun; | 154 | struct GNUNET_CADET_Channel *tun; |
@@ -159,10 +156,10 @@ timeout_cadet_task (void *cls) | |||
159 | sc->timeout_task = NULL; | 156 | sc->timeout_task = NULL; |
160 | tun = sc->channel; | 157 | tun = sc->channel; |
161 | sc->channel = NULL; | 158 | sc->channel = NULL; |
162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 159 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
163 | "Timeout for inactive cadet client %p\n", | 160 | "Timeout for inactive cadet client %p\n", |
164 | sc); | 161 | sc); |
165 | GNUNET_CADET_channel_destroy (tun); | 162 | GNUNET_CADET_channel_destroy(tun); |
166 | } | 163 | } |
167 | 164 | ||
168 | 165 | ||
@@ -172,13 +169,13 @@ timeout_cadet_task (void *cls) | |||
172 | * @param sc client handle to reset timeout for | 169 | * @param sc client handle to reset timeout for |
173 | */ | 170 | */ |
174 | static void | 171 | static void |
175 | refresh_timeout_task (struct CadetClient *sc) | 172 | refresh_timeout_task(struct CadetClient *sc) |
176 | { | 173 | { |
177 | if (NULL != sc->timeout_task) | 174 | if (NULL != sc->timeout_task) |
178 | GNUNET_SCHEDULER_cancel (sc->timeout_task); | 175 | GNUNET_SCHEDULER_cancel(sc->timeout_task); |
179 | sc->timeout_task = GNUNET_SCHEDULER_add_delayed (IDLE_TIMEOUT, | 176 | sc->timeout_task = GNUNET_SCHEDULER_add_delayed(IDLE_TIMEOUT, |
180 | &timeout_cadet_task, | 177 | &timeout_cadet_task, |
181 | sc); | 178 | sc); |
182 | } | 179 | } |
183 | 180 | ||
184 | 181 | ||
@@ -189,23 +186,23 @@ refresh_timeout_task (struct CadetClient *sc) | |||
189 | * @param cls where to process the write queue | 186 | * @param cls where to process the write queue |
190 | */ | 187 | */ |
191 | static void | 188 | static void |
192 | continue_writing (void *cls) | 189 | continue_writing(void *cls) |
193 | { | 190 | { |
194 | struct CadetClient *sc = cls; | 191 | struct CadetClient *sc = cls; |
195 | struct GNUNET_MQ_Handle *mq; | 192 | struct GNUNET_MQ_Handle *mq; |
196 | 193 | ||
197 | mq = GNUNET_CADET_get_mq (sc->channel); | 194 | mq = GNUNET_CADET_get_mq(sc->channel); |
198 | if (0 != GNUNET_MQ_get_length (mq)) | 195 | if (0 != GNUNET_MQ_get_length(mq)) |
199 | { | 196 | { |
200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 197 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
201 | "Write pending, waiting for it to complete\n"); | 198 | "Write pending, waiting for it to complete\n"); |
202 | return; | 199 | return; |
203 | } | 200 | } |
204 | refresh_timeout_task (sc); | 201 | refresh_timeout_task(sc); |
205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 202 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
206 | "Finished processing cadet request from client %p, ready to receive the next one\n", | 203 | "Finished processing cadet request from client %p, ready to receive the next one\n", |
207 | sc); | 204 | sc); |
208 | GNUNET_CADET_receive_done (sc->channel); | 205 | GNUNET_CADET_receive_done(sc->channel); |
209 | } | 206 | } |
210 | 207 | ||
211 | 208 | ||
@@ -225,103 +222,103 @@ continue_writing (void *cls) | |||
225 | * maybe 0 if no unique identifier is available | 222 | * maybe 0 if no unique identifier is available |
226 | */ | 223 | */ |
227 | static void | 224 | static void |
228 | handle_datastore_reply (void *cls, | 225 | handle_datastore_reply(void *cls, |
229 | const struct GNUNET_HashCode *key, | 226 | const struct GNUNET_HashCode *key, |
230 | size_t size, | 227 | size_t size, |
231 | const void *data, | 228 | const void *data, |
232 | enum GNUNET_BLOCK_Type type, | 229 | enum GNUNET_BLOCK_Type type, |
233 | uint32_t priority, | 230 | uint32_t priority, |
234 | uint32_t anonymity, | 231 | uint32_t anonymity, |
235 | uint32_t replication, | 232 | uint32_t replication, |
236 | struct GNUNET_TIME_Absolute expiration, | 233 | struct GNUNET_TIME_Absolute expiration, |
237 | uint64_t uid) | 234 | uint64_t uid) |
238 | { | 235 | { |
239 | struct CadetClient *sc = cls; | 236 | struct CadetClient *sc = cls; |
240 | size_t msize = size + sizeof (struct CadetReplyMessage); | 237 | size_t msize = size + sizeof(struct CadetReplyMessage); |
241 | struct GNUNET_MQ_Envelope *env; | 238 | struct GNUNET_MQ_Envelope *env; |
242 | struct CadetReplyMessage *srm; | 239 | struct CadetReplyMessage *srm; |
243 | 240 | ||
244 | sc->qe = NULL; | 241 | sc->qe = NULL; |
245 | if (NULL == data) | 242 | if (NULL == data) |
246 | { | ||
247 | /* no result, this should not really happen, as for | ||
248 | non-anonymous routing only peers that HAVE the | ||
249 | answers should be queried; OTOH, this is not a | ||
250 | hard error as we might have had the answer in the | ||
251 | past and the user might have unindexed it. Hence | ||
252 | we log at level "INFO" for now. */ | ||
253 | if (NULL == key) | ||
254 | { | ||
255 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
256 | "Have no answer and the query was NULL\n"); | ||
257 | } | ||
258 | else | ||
259 | { | 243 | { |
260 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 244 | /* no result, this should not really happen, as for |
261 | "Have no answer for query `%s'\n", | 245 | non-anonymous routing only peers that HAVE the |
262 | GNUNET_h2s (key)); | 246 | answers should be queried; OTOH, this is not a |
247 | hard error as we might have had the answer in the | ||
248 | past and the user might have unindexed it. Hence | ||
249 | we log at level "INFO" for now. */ | ||
250 | if (NULL == key) | ||
251 | { | ||
252 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
253 | "Have no answer and the query was NULL\n"); | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
258 | "Have no answer for query `%s'\n", | ||
259 | GNUNET_h2s(key)); | ||
260 | } | ||
261 | GNUNET_STATISTICS_update(GSF_stats, | ||
262 | gettext_noop("# queries received via CADET not answered"), | ||
263 | 1, | ||
264 | GNUNET_NO); | ||
265 | continue_writing(sc); | ||
266 | return; | ||
263 | } | 267 | } |
264 | GNUNET_STATISTICS_update (GSF_stats, | ||
265 | gettext_noop ("# queries received via CADET not answered"), | ||
266 | 1, | ||
267 | GNUNET_NO); | ||
268 | continue_writing (sc); | ||
269 | return; | ||
270 | } | ||
271 | if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type) | 268 | if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type) |
272 | { | ||
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
274 | "Performing on-demand encoding for query %s\n", | ||
275 | GNUNET_h2s (key)); | ||
276 | if (GNUNET_OK != | ||
277 | GNUNET_FS_handle_on_demand_block (key, | ||
278 | size, | ||
279 | data, | ||
280 | type, | ||
281 | priority, | ||
282 | anonymity, | ||
283 | replication, | ||
284 | expiration, | ||
285 | uid, | ||
286 | &handle_datastore_reply, | ||
287 | sc)) | ||
288 | { | 269 | { |
289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
290 | "On-demand encoding request failed\n"); | 271 | "Performing on-demand encoding for query %s\n", |
291 | continue_writing (sc); | 272 | GNUNET_h2s(key)); |
273 | if (GNUNET_OK != | ||
274 | GNUNET_FS_handle_on_demand_block(key, | ||
275 | size, | ||
276 | data, | ||
277 | type, | ||
278 | priority, | ||
279 | anonymity, | ||
280 | replication, | ||
281 | expiration, | ||
282 | uid, | ||
283 | &handle_datastore_reply, | ||
284 | sc)) | ||
285 | { | ||
286 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
287 | "On-demand encoding request failed\n"); | ||
288 | continue_writing(sc); | ||
289 | } | ||
290 | return; | ||
292 | } | 291 | } |
293 | return; | ||
294 | } | ||
295 | if (msize > GNUNET_MAX_MESSAGE_SIZE) | 292 | if (msize > GNUNET_MAX_MESSAGE_SIZE) |
296 | { | 293 | { |
297 | GNUNET_break (0); | 294 | GNUNET_break(0); |
298 | continue_writing (sc); | 295 | continue_writing(sc); |
299 | return; | 296 | return; |
300 | } | 297 | } |
301 | GNUNET_break (GNUNET_BLOCK_TYPE_ANY != type); | 298 | GNUNET_break(GNUNET_BLOCK_TYPE_ANY != type); |
302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 299 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
303 | "Starting transmission of %u byte reply of type %d for query `%s' via cadet to %p\n", | 300 | "Starting transmission of %u byte reply of type %d for query `%s' via cadet to %p\n", |
304 | (unsigned int) size, | 301 | (unsigned int)size, |
305 | (unsigned int) type, | 302 | (unsigned int)type, |
306 | GNUNET_h2s (key), | 303 | GNUNET_h2s(key), |
307 | sc); | 304 | sc); |
308 | env = GNUNET_MQ_msg_extra (srm, | 305 | env = GNUNET_MQ_msg_extra(srm, |
309 | size, | 306 | size, |
310 | GNUNET_MESSAGE_TYPE_FS_CADET_REPLY); | 307 | GNUNET_MESSAGE_TYPE_FS_CADET_REPLY); |
311 | srm->type = htonl (type); | 308 | srm->type = htonl(type); |
312 | srm->expiration = GNUNET_TIME_absolute_hton (expiration); | 309 | srm->expiration = GNUNET_TIME_absolute_hton(expiration); |
313 | GNUNET_memcpy (&srm[1], | 310 | GNUNET_memcpy(&srm[1], |
314 | data, | 311 | data, |
315 | size); | 312 | size); |
316 | GNUNET_MQ_notify_sent (env, | 313 | GNUNET_MQ_notify_sent(env, |
317 | &continue_writing, | 314 | &continue_writing, |
318 | sc); | 315 | sc); |
319 | GNUNET_STATISTICS_update (GSF_stats, | 316 | GNUNET_STATISTICS_update(GSF_stats, |
320 | gettext_noop ("# Blocks transferred via cadet"), | 317 | gettext_noop("# Blocks transferred via cadet"), |
321 | 1, | 318 | 1, |
322 | GNUNET_NO); | 319 | GNUNET_NO); |
323 | GNUNET_MQ_send (GNUNET_CADET_get_mq (sc->channel), | 320 | GNUNET_MQ_send(GNUNET_CADET_get_mq(sc->channel), |
324 | env); | 321 | env); |
325 | } | 322 | } |
326 | 323 | ||
327 | 324 | ||
@@ -333,35 +330,35 @@ handle_datastore_reply (void *cls, | |||
333 | * @param sqm the actual message | 330 | * @param sqm the actual message |
334 | */ | 331 | */ |
335 | static void | 332 | static void |
336 | handle_request (void *cls, | 333 | handle_request(void *cls, |
337 | const struct CadetQueryMessage *sqm) | 334 | const struct CadetQueryMessage *sqm) |
338 | { | 335 | { |
339 | struct CadetClient *sc = cls; | 336 | struct CadetClient *sc = cls; |
340 | 337 | ||
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 338 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
342 | "Received query for `%s' via cadet from client %p\n", | 339 | "Received query for `%s' via cadet from client %p\n", |
343 | GNUNET_h2s (&sqm->query), | 340 | GNUNET_h2s(&sqm->query), |
344 | sc); | 341 | sc); |
345 | GNUNET_STATISTICS_update (GSF_stats, | 342 | GNUNET_STATISTICS_update(GSF_stats, |
346 | gettext_noop ("# queries received via cadet"), | 343 | gettext_noop("# queries received via cadet"), |
347 | 1, | 344 | 1, |
348 | GNUNET_NO); | 345 | GNUNET_NO); |
349 | refresh_timeout_task (sc); | 346 | refresh_timeout_task(sc); |
350 | sc->qe = GNUNET_DATASTORE_get_key (GSF_dsh, | 347 | sc->qe = GNUNET_DATASTORE_get_key(GSF_dsh, |
351 | 0 /* next_uid */, | 348 | 0 /* next_uid */, |
352 | false /* random */, | 349 | false /* random */, |
353 | &sqm->query, | 350 | &sqm->query, |
354 | ntohl (sqm->type), | 351 | ntohl(sqm->type), |
355 | 0 /* priority */, | 352 | 0 /* priority */, |
356 | GSF_datastore_queue_size, | 353 | GSF_datastore_queue_size, |
357 | &handle_datastore_reply, | 354 | &handle_datastore_reply, |
358 | sc); | 355 | sc); |
359 | if (NULL == sc->qe) | 356 | if (NULL == sc->qe) |
360 | { | 357 | { |
361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 358 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
362 | "Queueing request with datastore failed (queue full?)\n"); | 359 | "Queueing request with datastore failed (queue full?)\n"); |
363 | continue_writing (sc); | 360 | continue_writing(sc); |
364 | } | 361 | } |
365 | } | 362 | } |
366 | 363 | ||
367 | 364 | ||
@@ -375,37 +372,37 @@ handle_request (void *cls, | |||
375 | * @return initial channel context (our `struct CadetClient`) | 372 | * @return initial channel context (our `struct CadetClient`) |
376 | */ | 373 | */ |
377 | static void * | 374 | static void * |
378 | connect_cb (void *cls, | 375 | connect_cb(void *cls, |
379 | struct GNUNET_CADET_Channel *channel, | 376 | struct GNUNET_CADET_Channel *channel, |
380 | const struct GNUNET_PeerIdentity *initiator) | 377 | const struct GNUNET_PeerIdentity *initiator) |
381 | { | 378 | { |
382 | struct CadetClient *sc; | 379 | struct CadetClient *sc; |
383 | 380 | ||
384 | GNUNET_assert (NULL != channel); | 381 | GNUNET_assert(NULL != channel); |
385 | if (sc_count >= sc_count_max) | 382 | if (sc_count >= sc_count_max) |
386 | { | 383 | { |
387 | GNUNET_STATISTICS_update (GSF_stats, | 384 | GNUNET_STATISTICS_update(GSF_stats, |
388 | gettext_noop ("# cadet client connections rejected"), | 385 | gettext_noop("# cadet client connections rejected"), |
389 | 1, | 386 | 1, |
390 | GNUNET_NO); | 387 | GNUNET_NO); |
391 | GNUNET_CADET_channel_destroy (channel); | 388 | GNUNET_CADET_channel_destroy(channel); |
392 | return NULL; | 389 | return NULL; |
393 | } | 390 | } |
394 | GNUNET_STATISTICS_update (GSF_stats, | 391 | GNUNET_STATISTICS_update(GSF_stats, |
395 | gettext_noop ("# cadet connections active"), | 392 | gettext_noop("# cadet connections active"), |
396 | 1, | 393 | 1, |
397 | GNUNET_NO); | 394 | GNUNET_NO); |
398 | sc = GNUNET_new (struct CadetClient); | 395 | sc = GNUNET_new(struct CadetClient); |
399 | sc->channel = channel; | 396 | sc->channel = channel; |
400 | GNUNET_CONTAINER_DLL_insert (sc_head, | 397 | GNUNET_CONTAINER_DLL_insert(sc_head, |
401 | sc_tail, | 398 | sc_tail, |
402 | sc); | 399 | sc); |
403 | sc_count++; | 400 | sc_count++; |
404 | refresh_timeout_task (sc); | 401 | refresh_timeout_task(sc); |
405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 402 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
406 | "Accepting inbound cadet connection from `%s' as client %p\n", | 403 | "Accepting inbound cadet connection from `%s' as client %p\n", |
407 | GNUNET_i2s (initiator), | 404 | GNUNET_i2s(initiator), |
408 | sc); | 405 | sc); |
409 | return sc; | 406 | return sc; |
410 | } | 407 | } |
411 | 408 | ||
@@ -419,8 +416,8 @@ connect_cb (void *cls, | |||
419 | * @param channel_ctx | 416 | * @param channel_ctx |
420 | */ | 417 | */ |
421 | static void | 418 | static void |
422 | disconnect_cb (void *cls, | 419 | disconnect_cb(void *cls, |
423 | const struct GNUNET_CADET_Channel *channel) | 420 | const struct GNUNET_CADET_Channel *channel) |
424 | { | 421 | { |
425 | struct CadetClient *sc = cls; | 422 | struct CadetClient *sc = cls; |
426 | struct WriteQueueItem *wqi; | 423 | struct WriteQueueItem *wqi; |
@@ -428,30 +425,30 @@ disconnect_cb (void *cls, | |||
428 | if (NULL == sc) | 425 | if (NULL == sc) |
429 | return; | 426 | return; |
430 | sc->channel = NULL; | 427 | sc->channel = NULL; |
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 428 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
432 | "Terminating cadet connection with client %p\n", | 429 | "Terminating cadet connection with client %p\n", |
433 | sc); | 430 | sc); |
434 | GNUNET_STATISTICS_update (GSF_stats, | 431 | GNUNET_STATISTICS_update(GSF_stats, |
435 | gettext_noop ("# cadet connections active"), -1, | 432 | gettext_noop("# cadet connections active"), -1, |
436 | GNUNET_NO); | 433 | GNUNET_NO); |
437 | if (NULL != sc->terminate_task) | 434 | if (NULL != sc->terminate_task) |
438 | GNUNET_SCHEDULER_cancel (sc->terminate_task); | 435 | GNUNET_SCHEDULER_cancel(sc->terminate_task); |
439 | if (NULL != sc->timeout_task) | 436 | if (NULL != sc->timeout_task) |
440 | GNUNET_SCHEDULER_cancel (sc->timeout_task); | 437 | GNUNET_SCHEDULER_cancel(sc->timeout_task); |
441 | if (NULL != sc->qe) | 438 | if (NULL != sc->qe) |
442 | GNUNET_DATASTORE_cancel (sc->qe); | 439 | GNUNET_DATASTORE_cancel(sc->qe); |
443 | while (NULL != (wqi = sc->wqi_head)) | 440 | while (NULL != (wqi = sc->wqi_head)) |
444 | { | 441 | { |
445 | GNUNET_CONTAINER_DLL_remove (sc->wqi_head, | 442 | GNUNET_CONTAINER_DLL_remove(sc->wqi_head, |
446 | sc->wqi_tail, | 443 | sc->wqi_tail, |
447 | wqi); | 444 | wqi); |
448 | GNUNET_free (wqi); | 445 | GNUNET_free(wqi); |
449 | } | 446 | } |
450 | GNUNET_CONTAINER_DLL_remove (sc_head, | 447 | GNUNET_CONTAINER_DLL_remove(sc_head, |
451 | sc_tail, | 448 | sc_tail, |
452 | sc); | 449 | sc); |
453 | sc_count--; | 450 | sc_count--; |
454 | GNUNET_free (sc); | 451 | GNUNET_free(sc); |
455 | } | 452 | } |
456 | 453 | ||
457 | 454 | ||
@@ -470,9 +467,9 @@ disconnect_cb (void *cls, | |||
470 | * this value will be negative.. | 467 | * this value will be negative.. |
471 | */ | 468 | */ |
472 | static void | 469 | static void |
473 | window_change_cb (void *cls, | 470 | window_change_cb(void *cls, |
474 | const struct GNUNET_CADET_Channel *channel, | 471 | const struct GNUNET_CADET_Channel *channel, |
475 | int window_size) | 472 | int window_size) |
476 | { | 473 | { |
477 | /* FIXME: could do flow control here... */ | 474 | /* FIXME: could do flow control here... */ |
478 | } | 475 | } |
@@ -482,39 +479,39 @@ window_change_cb (void *cls, | |||
482 | * Initialize subsystem for non-anonymous file-sharing. | 479 | * Initialize subsystem for non-anonymous file-sharing. |
483 | */ | 480 | */ |
484 | void | 481 | void |
485 | GSF_cadet_start_server () | 482 | GSF_cadet_start_server() |
486 | { | 483 | { |
487 | struct GNUNET_MQ_MessageHandler handlers[] = { | 484 | struct GNUNET_MQ_MessageHandler handlers[] = { |
488 | GNUNET_MQ_hd_fixed_size (request, | 485 | GNUNET_MQ_hd_fixed_size(request, |
489 | GNUNET_MESSAGE_TYPE_FS_CADET_QUERY, | 486 | GNUNET_MESSAGE_TYPE_FS_CADET_QUERY, |
490 | struct CadetQueryMessage, | 487 | struct CadetQueryMessage, |
491 | NULL), | 488 | NULL), |
492 | GNUNET_MQ_handler_end () | 489 | GNUNET_MQ_handler_end() |
493 | }; | 490 | }; |
494 | struct GNUNET_HashCode port; | 491 | struct GNUNET_HashCode port; |
495 | 492 | ||
496 | if (GNUNET_YES != | 493 | if (GNUNET_YES != |
497 | GNUNET_CONFIGURATION_get_value_number (GSF_cfg, | 494 | GNUNET_CONFIGURATION_get_value_number(GSF_cfg, |
498 | "fs", | 495 | "fs", |
499 | "MAX_CADET_CLIENTS", | 496 | "MAX_CADET_CLIENTS", |
500 | &sc_count_max)) | 497 | &sc_count_max)) |
501 | return; | 498 | return; |
502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 499 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
503 | "Initializing cadet FS server with a limit of %llu connections\n", | 500 | "Initializing cadet FS server with a limit of %llu connections\n", |
504 | sc_count_max); | 501 | sc_count_max); |
505 | cadet_map = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | 502 | cadet_map = GNUNET_CONTAINER_multipeermap_create(16, GNUNET_YES); |
506 | cadet_handle = GNUNET_CADET_connect (GSF_cfg); | 503 | cadet_handle = GNUNET_CADET_connect(GSF_cfg); |
507 | GNUNET_assert (NULL != cadet_handle); | 504 | GNUNET_assert(NULL != cadet_handle); |
508 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, | 505 | GNUNET_CRYPTO_hash(GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, |
509 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), | 506 | strlen(GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), |
510 | &port); | 507 | &port); |
511 | cadet_port = GNUNET_CADET_open_port (cadet_handle, | 508 | cadet_port = GNUNET_CADET_open_port(cadet_handle, |
512 | &port, | 509 | &port, |
513 | &connect_cb, | 510 | &connect_cb, |
514 | NULL, | 511 | NULL, |
515 | &window_change_cb, | 512 | &window_change_cb, |
516 | &disconnect_cb, | 513 | &disconnect_cb, |
517 | handlers); | 514 | handlers); |
518 | } | 515 | } |
519 | 516 | ||
520 | 517 | ||
@@ -522,25 +519,25 @@ GSF_cadet_start_server () | |||
522 | * Shutdown subsystem for non-anonymous file-sharing. | 519 | * Shutdown subsystem for non-anonymous file-sharing. |
523 | */ | 520 | */ |
524 | void | 521 | void |
525 | GSF_cadet_stop_server () | 522 | GSF_cadet_stop_server() |
526 | { | 523 | { |
527 | GNUNET_CONTAINER_multipeermap_iterate (cadet_map, | 524 | GNUNET_CONTAINER_multipeermap_iterate(cadet_map, |
528 | &GSF_cadet_release_clients, | 525 | &GSF_cadet_release_clients, |
529 | NULL); | 526 | NULL); |
530 | GNUNET_CONTAINER_multipeermap_destroy (cadet_map); | 527 | GNUNET_CONTAINER_multipeermap_destroy(cadet_map); |
531 | cadet_map = NULL; | 528 | cadet_map = NULL; |
532 | if (NULL != cadet_port) | 529 | if (NULL != cadet_port) |
533 | { | 530 | { |
534 | GNUNET_CADET_close_port (cadet_port); | 531 | GNUNET_CADET_close_port(cadet_port); |
535 | cadet_port = NULL; | 532 | cadet_port = NULL; |
536 | } | 533 | } |
537 | if (NULL != cadet_handle) | 534 | if (NULL != cadet_handle) |
538 | { | 535 | { |
539 | GNUNET_CADET_disconnect (cadet_handle); | 536 | GNUNET_CADET_disconnect(cadet_handle); |
540 | cadet_handle = NULL; | 537 | cadet_handle = NULL; |
541 | } | 538 | } |
542 | GNUNET_assert (NULL == sc_head); | 539 | GNUNET_assert(NULL == sc_head); |
543 | GNUNET_assert (0 == sc_count); | 540 | GNUNET_assert(0 == sc_count); |
544 | } | 541 | } |
545 | 542 | ||
546 | /* end of gnunet-service-fs_cadet.c */ | 543 | /* end of gnunet-service-fs_cadet.c */ |