diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/core/gnunet-service-core_neighbours.c | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/core/gnunet-service-core_neighbours.c')
-rw-r--r-- | src/core/gnunet-service-core_neighbours.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index d7ce91a88..5014298bf 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c | |||
@@ -158,10 +158,10 @@ free_neighbour (struct Neighbour *n) | |||
158 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th); | 158 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th); |
159 | n->th = NULL; | 159 | n->th = NULL; |
160 | } | 160 | } |
161 | GNUNET_STATISTICS_update (GSC_stats, | 161 | GNUNET_STATISTICS_update (GSC_stats, |
162 | gettext_noop ("# sessions terminated by transport disconnect"), | 162 | gettext_noop |
163 | 1, | 163 | ("# sessions terminated by transport disconnect"), |
164 | GNUNET_NO); | 164 | 1, GNUNET_NO); |
165 | GSC_SESSIONS_end (&n->peer); | 165 | GSC_SESSIONS_end (&n->peer); |
166 | if (NULL != n->kxinfo) | 166 | if (NULL != n->kxinfo) |
167 | { | 167 | { |
@@ -175,8 +175,9 @@ free_neighbour (struct Neighbour *n) | |||
175 | } | 175 | } |
176 | GNUNET_assert (GNUNET_OK == | 176 | GNUNET_assert (GNUNET_OK == |
177 | GNUNET_CONTAINER_multihashmap_remove (neighbours, | 177 | GNUNET_CONTAINER_multihashmap_remove (neighbours, |
178 | &n->peer.hashPubKey, n)); | 178 | &n->peer.hashPubKey, n)); |
179 | GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"), | 179 | GNUNET_STATISTICS_set (GSC_stats, |
180 | gettext_noop ("# neighbour entries allocated"), | ||
180 | GNUNET_CONTAINER_multihashmap_size (neighbours), | 181 | GNUNET_CONTAINER_multihashmap_size (neighbours), |
181 | GNUNET_NO); | 182 | GNUNET_NO); |
182 | GNUNET_free (n); | 183 | GNUNET_free (n); |
@@ -239,10 +240,10 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
239 | ret = m->size; | 240 | ret = m->size; |
240 | #if DEBUG_CORE | 241 | #if DEBUG_CORE |
241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
242 | "Copied message of type %u and size %u into transport buffer for `%4s'\n", | 243 | "Copied message of type %u and size %u into transport buffer for `%4s'\n", |
243 | (unsigned int) | 244 | (unsigned int) |
244 | ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), | 245 | ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), |
245 | (unsigned int) ret, GNUNET_i2s (&n->peer)); | 246 | (unsigned int) ret, GNUNET_i2s (&n->peer)); |
246 | #endif | 247 | #endif |
247 | GNUNET_free (m); | 248 | GNUNET_free (m); |
248 | process_queue (n); | 249 | process_queue (n); |
@@ -271,7 +272,7 @@ process_queue (struct Neighbour *n) | |||
271 | if (m == NULL) | 272 | if (m == NULL) |
272 | { | 273 | { |
273 | /* notify sessions that the queue is empty and more messages | 274 | /* notify sessions that the queue is empty and more messages |
274 | could thus be queued now */ | 275 | * could thus be queued now */ |
275 | GSC_SESSIONS_solicit (&n->peer); | 276 | GSC_SESSIONS_solicit (&n->peer); |
276 | return; | 277 | return; |
277 | } | 278 | } |
@@ -283,12 +284,10 @@ process_queue (struct Neighbour *n) | |||
283 | GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value); | 284 | GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value); |
284 | #endif | 285 | #endif |
285 | n->th = | 286 | n->th = |
286 | GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, | 287 | GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0, |
287 | 0, | 288 | GNUNET_TIME_absolute_get_remaining |
288 | GNUNET_TIME_absolute_get_remaining | 289 | (m->deadline), &transmit_ready, |
289 | (m->deadline), | 290 | n); |
290 | &transmit_ready, | ||
291 | n); | ||
292 | if (n->th != NULL) | 291 | if (n->th != NULL) |
293 | return; | 292 | return; |
294 | /* message request too large or duplicate request */ | 293 | /* message request too large or duplicate request */ |
@@ -313,8 +312,8 @@ process_queue (struct Neighbour *n) | |||
313 | static void | 312 | static void |
314 | handle_transport_notify_connect (void *cls, | 313 | handle_transport_notify_connect (void *cls, |
315 | const struct GNUNET_PeerIdentity *peer, | 314 | const struct GNUNET_PeerIdentity *peer, |
316 | const struct GNUNET_ATS_Information | 315 | const struct GNUNET_ATS_Information *atsi, |
317 | *atsi, uint32_t atsi_count) | 316 | uint32_t atsi_count) |
318 | { | 317 | { |
319 | struct Neighbour *n; | 318 | struct Neighbour *n; |
320 | 319 | ||
@@ -340,7 +339,8 @@ handle_transport_notify_connect (void *cls, | |||
340 | GNUNET_CONTAINER_multihashmap_put (neighbours, | 339 | GNUNET_CONTAINER_multihashmap_put (neighbours, |
341 | &n->peer.hashPubKey, n, | 340 | &n->peer.hashPubKey, n, |
342 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 341 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
343 | GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"), | 342 | GNUNET_STATISTICS_set (GSC_stats, |
343 | gettext_noop ("# neighbour entries allocated"), | ||
344 | GNUNET_CONTAINER_multihashmap_size (neighbours), | 344 | GNUNET_CONTAINER_multihashmap_size (neighbours), |
345 | GNUNET_NO); | 345 | GNUNET_NO); |
346 | n->kxinfo = GSC_KX_start (peer); | 346 | n->kxinfo = GSC_KX_start (peer); |
@@ -423,9 +423,7 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
423 | GSC_KX_handle_pong (n->kxinfo, message); | 423 | GSC_KX_handle_pong (n->kxinfo, message); |
424 | break; | 424 | break; |
425 | case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: | 425 | case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: |
426 | GSC_KX_handle_encrypted_message (n->kxinfo, | 426 | GSC_KX_handle_encrypted_message (n->kxinfo, message, atsi, atsi_count); |
427 | message, atsi, | ||
428 | atsi_count); | ||
429 | break; | 427 | break; |
430 | default: | 428 | default: |
431 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 429 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -438,15 +436,15 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
438 | 436 | ||
439 | /** | 437 | /** |
440 | * Transmit the given message to the given target. | 438 | * Transmit the given message to the given target. |
441 | * | 439 | * |
442 | * @param target peer that should receive the message (must be connected) | 440 | * @param target peer that should receive the message (must be connected) |
443 | * @param msg message to transmit | 441 | * @param msg message to transmit |
444 | * @param timeout by when should the transmission be done? | 442 | * @param timeout by when should the transmission be done? |
445 | */ | 443 | */ |
446 | void | 444 | void |
447 | GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, | 445 | GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, |
448 | const struct GNUNET_MessageHeader *msg, | 446 | const struct GNUNET_MessageHeader *msg, |
449 | struct GNUNET_TIME_Relative timeout) | 447 | struct GNUNET_TIME_Relative timeout) |
450 | { | 448 | { |
451 | struct NeighbourMessageEntry *me; | 449 | struct NeighbourMessageEntry *me; |
452 | struct Neighbour *n; | 450 | struct Neighbour *n; |
@@ -463,9 +461,7 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, | |||
463 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); | 461 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); |
464 | me->size = msize; | 462 | me->size = msize; |
465 | memcpy (&me[1], msg, msize); | 463 | memcpy (&me[1], msg, msize); |
466 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, | 464 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me); |
467 | n->message_tail, | ||
468 | me); | ||
469 | process_queue (n); | 465 | process_queue (n); |
470 | } | 466 | } |
471 | 467 | ||
@@ -478,8 +474,7 @@ GSC_NEIGHBOURS_init () | |||
478 | { | 474 | { |
479 | neighbours = GNUNET_CONTAINER_multihashmap_create (128); | 475 | neighbours = GNUNET_CONTAINER_multihashmap_create (128); |
480 | transport = | 476 | transport = |
481 | GNUNET_TRANSPORT_connect (GSC_cfg, | 477 | GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL, |
482 | &GSC_my_identity, NULL, | ||
483 | &handle_transport_receive, | 478 | &handle_transport_receive, |
484 | &handle_transport_notify_connect, | 479 | &handle_transport_notify_connect, |
485 | &handle_transport_notify_disconnect); | 480 | &handle_transport_notify_disconnect); |
@@ -530,4 +525,3 @@ GSC_NEIGHBOURS_done () | |||
530 | } | 525 | } |
531 | 526 | ||
532 | /* end of gnunet-service-core_neighbours.c */ | 527 | /* end of gnunet-service-core_neighbours.c */ |
533 | |||