diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-21 19:45:41 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-21 19:45:41 +0100 |
commit | 742aa628e2045b947a9e55b60b0e976ea6658c9a (patch) | |
tree | eade56d7ee1a30281f94e1af8cec2da57e35e5db /src/cadet/gnunet-service-cadet-new_connection.c | |
parent | 308518cb6fbc4b635fccd87a770f66cc2e2816f3 (diff) | |
download | gnunet-742aa628e2045b947a9e55b60b0e976ea6658c9a.tar.gz gnunet-742aa628e2045b947a9e55b60b0e976ea6658c9a.zip |
more logging, minor bugfixes / renames
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_connection.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_connection.c | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 5eb6335a2..55b33e224 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c | |||
@@ -40,6 +40,9 @@ | |||
40 | #include "cadet_protocol.h" | 40 | #include "cadet_protocol.h" |
41 | 41 | ||
42 | 42 | ||
43 | #define LOG(level, ...) GNUNET_log_from(level,"cadet-con",__VA_ARGS__) | ||
44 | |||
45 | |||
43 | /** | 46 | /** |
44 | * All the states a connection can be in. | 47 | * All the states a connection can be in. |
45 | */ | 48 | */ |
@@ -158,6 +161,9 @@ GCC_destroy (struct CadetConnection *cc) | |||
158 | { | 161 | { |
159 | struct GNUNET_MQ_Envelope *env = NULL; | 162 | struct GNUNET_MQ_Envelope *env = NULL; |
160 | 163 | ||
164 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
165 | "Destroying connection %s\n", | ||
166 | GCC_2s (cc)); | ||
161 | if (CADET_CONNECTION_SENDING_CREATE != cc->state) | 167 | if (CADET_CONNECTION_SENDING_CREATE != cc->state) |
162 | { | 168 | { |
163 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; | 169 | struct GNUNET_CADET_ConnectionDestroyMessage *destroy_msg; |
@@ -201,8 +207,12 @@ GCC_get_ct (struct CadetConnection *cc) | |||
201 | * @param cc the connection that got the ACK. | 207 | * @param cc the connection that got the ACK. |
202 | */ | 208 | */ |
203 | void | 209 | void |
204 | GCC_handle_connection_ack (struct CadetConnection *cc) | 210 | GCC_handle_connection_create_ack (struct CadetConnection *cc) |
205 | { | 211 | { |
212 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
213 | "Received CREATE_ACK for connection %s in state %d\n", | ||
214 | GCC_2s (cc), | ||
215 | cc->state); | ||
206 | if (NULL != cc->task) | 216 | if (NULL != cc->task) |
207 | { | 217 | { |
208 | GNUNET_SCHEDULER_cancel (cc->task); | 218 | GNUNET_SCHEDULER_cancel (cc->task); |
@@ -234,7 +244,10 @@ GCC_handle_kx (struct CadetConnection *cc, | |||
234 | { | 244 | { |
235 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, | 245 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, |
236 | clearly something is working, so pretend we got an ACK. */ | 246 | clearly something is working, so pretend we got an ACK. */ |
237 | GCC_handle_connection_ack (cc); | 247 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
248 | "Faking connection ACK for connection %s due to KX\n", | ||
249 | GCC_2s (cc)); | ||
250 | GCC_handle_connection_create_ack (cc); | ||
238 | } | 251 | } |
239 | GCT_handle_kx (cc->ct, | 252 | GCT_handle_kx (cc->ct, |
240 | msg); | 253 | msg); |
@@ -255,7 +268,10 @@ GCC_handle_encrypted (struct CadetConnection *cc, | |||
255 | { | 268 | { |
256 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, | 269 | /* We didn't get the CREATE_ACK, but instead got payload. That's fine, |
257 | clearly something is working, so pretend we got an ACK. */ | 270 | clearly something is working, so pretend we got an ACK. */ |
258 | GCC_handle_connection_ack (cc); | 271 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
272 | "Faking connection ACK for connection %s due to ENCRYPTED payload\n", | ||
273 | GCC_2s (cc)); | ||
274 | GCC_handle_connection_create_ack (cc); | ||
259 | } | 275 | } |
260 | GCT_handle_encrypted (cc->ct, | 276 | GCT_handle_encrypted (cc->ct, |
261 | msg); | 277 | msg); |
@@ -287,6 +303,9 @@ send_create (void *cls) | |||
287 | for (unsigned int i=0;i<path_length;i++) | 303 | for (unsigned int i=0;i<path_length;i++) |
288 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, | 304 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, |
289 | i)); | 305 | i)); |
306 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
307 | "Sending CONNECTION_CREATE message for connection %s\n", | ||
308 | GCC_2s (cc)); | ||
290 | cc->env = env; | 309 | cc->env = env; |
291 | cc->mqm_ready = GNUNET_NO; | 310 | cc->mqm_ready = GNUNET_NO; |
292 | cc->state = CADET_CONNECTION_SENT; | 311 | cc->state = CADET_CONNECTION_SENT; |
@@ -304,22 +323,17 @@ static void | |||
304 | send_create_ack (void *cls) | 323 | send_create_ack (void *cls) |
305 | { | 324 | { |
306 | struct CadetConnection *cc = cls; | 325 | struct CadetConnection *cc = cls; |
307 | struct GNUNET_CADET_ConnectionCreateMessage *create_msg; | 326 | struct GNUNET_CADET_ConnectionCreateAckMessage *ack_msg; |
308 | struct GNUNET_PeerIdentity *pids; | ||
309 | struct GNUNET_MQ_Envelope *env; | 327 | struct GNUNET_MQ_Envelope *env; |
310 | unsigned int path_length; | ||
311 | 328 | ||
312 | cc->task = NULL; | 329 | cc->task = NULL; |
330 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
331 | "Sending CONNECTION_CREATE_ACK message for connection %s\n", | ||
332 | GCC_2s (cc)); | ||
313 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 333 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
314 | path_length = GCPP_get_length (cc->path); | 334 | env = GNUNET_MQ_msg (ack_msg, |
315 | env = GNUNET_MQ_msg_extra (create_msg, | 335 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK); |
316 | path_length * sizeof (struct GNUNET_PeerIdentity), | 336 | ack_msg->cid = cc->cid; |
317 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); | ||
318 | create_msg->cid = cc->cid; | ||
319 | pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; | ||
320 | for (unsigned int i=0;i<path_length;i++) | ||
321 | pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, | ||
322 | i)); | ||
323 | cc->env = env; | 337 | cc->env = env; |
324 | cc->mqm_ready = GNUNET_NO; | 338 | cc->mqm_ready = GNUNET_NO; |
325 | cc->state = CADET_CONNECTION_READY; | 339 | cc->state = CADET_CONNECTION_READY; |
@@ -340,11 +354,13 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
340 | { | 354 | { |
341 | if (GNUNET_YES == cc->mqm_ready) | 355 | if (GNUNET_YES == cc->mqm_ready) |
342 | { | 356 | { |
357 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
358 | "Got duplicate CREATE for connection %s, scheduling another ACK\n", | ||
359 | GCC_2s (cc)); | ||
343 | /* Tell tunnel that we are not ready for transmission anymore | 360 | /* Tell tunnel that we are not ready for transmission anymore |
344 | (until CREATE_ACK is done) */ | 361 | (until CREATE_ACK is done) */ |
345 | cc->ready_cb (cc->ready_cb_cls, | 362 | cc->ready_cb (cc->ready_cb_cls, |
346 | GNUNET_NO); | 363 | GNUNET_NO); |
347 | |||
348 | /* Revert back to the state of having only received the 'CREATE', | 364 | /* Revert back to the state of having only received the 'CREATE', |
349 | and immediately proceed to send the CREATE_ACK. */ | 365 | and immediately proceed to send the CREATE_ACK. */ |
350 | cc->state = CADET_CONNECTION_CREATE_RECEIVED; | 366 | cc->state = CADET_CONNECTION_CREATE_RECEIVED; |
@@ -356,6 +372,9 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) | |||
356 | /* We are currently sending something else back, which | 372 | /* We are currently sending something else back, which |
357 | can only be an ACK or payload, either of which would | 373 | can only be an ACK or payload, either of which would |
358 | do. So actually no need to do anything. */ | 374 | do. So actually no need to do anything. */ |
375 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
376 | "Got duplicate CREATE for connection %s. MQ is busy, not queueing another ACK\n", | ||
377 | GCC_2s (cc)); | ||
359 | } | 378 | } |
360 | } | 379 | } |
361 | 380 | ||
@@ -379,6 +398,9 @@ manage_first_hop_mq (void *cls, | |||
379 | if (GNUNET_YES != available) | 398 | if (GNUNET_YES != available) |
380 | { | 399 | { |
381 | /* Connection is down, for now... */ | 400 | /* Connection is down, for now... */ |
401 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
402 | "Core MQ for connection %s went down\n", | ||
403 | GCC_2s (cc)); | ||
382 | cc->mqm_ready = GNUNET_NO; | 404 | cc->mqm_ready = GNUNET_NO; |
383 | cc->state = CADET_CONNECTION_NEW; | 405 | cc->state = CADET_CONNECTION_NEW; |
384 | cc->retry_delay = GNUNET_TIME_UNIT_ZERO; | 406 | cc->retry_delay = GNUNET_TIME_UNIT_ZERO; |
@@ -393,6 +415,10 @@ manage_first_hop_mq (void *cls, | |||
393 | } | 415 | } |
394 | 416 | ||
395 | cc->mqm_ready = GNUNET_YES; | 417 | cc->mqm_ready = GNUNET_YES; |
418 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
419 | "Core MQ for connection %s became available in state %d\n", | ||
420 | GCC_2s (cc), | ||
421 | cc->state); | ||
396 | switch (cc->state) | 422 | switch (cc->state) |
397 | { | 423 | { |
398 | case CADET_CONNECTION_NEW: | 424 | case CADET_CONNECTION_NEW: |
@@ -479,6 +505,10 @@ connection_create (struct CadetPeer *destination, | |||
479 | cc->mq_man = GCP_request_mq (first_hop, | 505 | cc->mq_man = GCP_request_mq (first_hop, |
480 | &manage_first_hop_mq, | 506 | &manage_first_hop_mq, |
481 | cc); | 507 | cc); |
508 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
509 | "Created connection %s using path %s\n", | ||
510 | GCC_2s (cc), | ||
511 | GCPP_2s (path)); | ||
482 | return cc; | 512 | return cc; |
483 | } | 513 | } |
484 | 514 | ||
@@ -560,6 +590,9 @@ void | |||
560 | GCC_transmit (struct CadetConnection *cc, | 590 | GCC_transmit (struct CadetConnection *cc, |
561 | struct GNUNET_MQ_Envelope *env) | 591 | struct GNUNET_MQ_Envelope *env) |
562 | { | 592 | { |
593 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
594 | "Scheduling message for transmission on %s\n", | ||
595 | GCC_2s (cc)); | ||
563 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); | 596 | GNUNET_assert (GNUNET_YES == cc->mqm_ready); |
564 | GNUNET_assert (CADET_CONNECTION_READY == cc->state); | 597 | GNUNET_assert (CADET_CONNECTION_READY == cc->state); |
565 | cc->mqm_ready = GNUNET_NO; | 598 | cc->mqm_ready = GNUNET_NO; |