diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-11 19:21:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-11 19:21:05 +0000 |
commit | 31c87758dc6653f9363313d2bc489012219fe619 (patch) | |
tree | 34311ccc4603aba0426486016c61f55c5b945bef /src | |
parent | 26c01bc5b1e150d81e7137804295e6d6c6cc9da9 (diff) | |
download | gnunet-31c87758dc6653f9363313d2bc489012219fe619.tar.gz gnunet-31c87758dc6653f9363313d2bc489012219fe619.zip |
#ifdef debug code
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/gnunet-service-manager.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/arm/gnunet-service-manager.c b/src/arm/gnunet-service-manager.c index 8a4e5a2bf..2a4d0c27f 100644 --- a/src/arm/gnunet-service-manager.c +++ b/src/arm/gnunet-service-manager.c | |||
@@ -192,8 +192,10 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, int reason) | |||
192 | if ( (fc->clientReceivingTask != GNUNET_SCHEDULER_NO_TASK) || | 192 | if ( (fc->clientReceivingTask != GNUNET_SCHEDULER_NO_TASK) || |
193 | (fc->serviceReceivingTask != GNUNET_SCHEDULER_NO_TASK) ) | 193 | (fc->serviceReceivingTask != GNUNET_SCHEDULER_NO_TASK) ) |
194 | return; | 194 | return; |
195 | #if DEBUG_SERVICE_MANAGER | ||
195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | "Closing forwarding connection (done with both directions)\n"); | 197 | "Closing forwarding connection (done with both directions)\n"); |
198 | #endif | ||
197 | if ( (NULL != fc->armClientSocket) && | 199 | if ( (NULL != fc->armClientSocket) && |
198 | (GNUNET_SYSERR == | 200 | (GNUNET_SYSERR == |
199 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) | 201 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) |
@@ -244,9 +246,11 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
244 | GNUNET_NETWORK_socket_send (fc->armClientSocket, | 246 | GNUNET_NETWORK_socket_send (fc->armClientSocket, |
245 | fc->serviceBufferPos, | 247 | fc->serviceBufferPos, |
246 | fc->serviceBufferDataLength); | 248 | fc->serviceBufferDataLength); |
249 | #if DEBUG_SERVICE_MANAGER | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
248 | "Forwarded %d bytes to client\n", | 251 | "Forwarded %d bytes to client\n", |
249 | numberOfBytesSent); | 252 | numberOfBytesSent); |
253 | #endif | ||
250 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) | 254 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) |
251 | { | 255 | { |
252 | /* Error occured or connection closed by client */ | 256 | /* Error occured or connection closed by client */ |
@@ -307,17 +311,21 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
307 | GNUNET_NETWORK_socket_recv (fc->armServiceSocket, | 311 | GNUNET_NETWORK_socket_recv (fc->armServiceSocket, |
308 | fc->serviceBuffer, BUFFER_SIZE); | 312 | fc->serviceBuffer, BUFFER_SIZE); |
309 | 313 | ||
314 | #if DEBUG_SERVICE_MANAGER | ||
310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
311 | "Received %d bytes for client\n", | 316 | "Received %d bytes for client\n", |
312 | fc->serviceBufferDataLength); | 317 | fc->serviceBufferDataLength); |
318 | #endif | ||
313 | if (fc->serviceBufferDataLength <= 0) | 319 | if (fc->serviceBufferDataLength <= 0) |
314 | { | 320 | { |
315 | /* The service has closed the connection or an error occured */ | 321 | /* The service has closed the connection or an error occured */ |
316 | if (fc->serviceBufferDataLength == 0) | 322 | if (fc->serviceBufferDataLength == 0) |
317 | { | 323 | { |
324 | #if DEBUG_SERVICE_MANAGER | ||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
319 | _("Service `%s' closed connection! \n"), | 326 | _("Service `%s' closed connection! \n"), |
320 | fc->listen_info->serviceName); | 327 | fc->listen_info->serviceName); |
328 | #endif | ||
321 | } | 329 | } |
322 | else | 330 | else |
323 | { | 331 | { |
@@ -366,9 +374,11 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
366 | GNUNET_NETWORK_socket_send (fc->armServiceSocket, | 374 | GNUNET_NETWORK_socket_send (fc->armServiceSocket, |
367 | fc->clientBufferPos, | 375 | fc->clientBufferPos, |
368 | fc->clientBufferDataLength); | 376 | fc->clientBufferDataLength); |
377 | #if DEBUG_SERVICE_MANAGER | ||
369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 378 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
370 | "Forwarded %d bytes to service\n", | 379 | "Forwarded %d bytes to service\n", |
371 | numberOfBytesSent); | 380 | numberOfBytesSent); |
381 | #endif | ||
372 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) | 382 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) |
373 | { | 383 | { |
374 | /* Error occured or connection closed by service */ | 384 | /* Error occured or connection closed by service */ |
@@ -431,20 +441,28 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
431 | fc->clientBufferDataLength = | 441 | fc->clientBufferDataLength = |
432 | GNUNET_NETWORK_socket_recv (fc->armClientSocket, | 442 | GNUNET_NETWORK_socket_recv (fc->armClientSocket, |
433 | fc->clientBuffer, BUFFER_SIZE); | 443 | fc->clientBuffer, BUFFER_SIZE); |
444 | #if DEBUG_SERVICE_MANAGER | ||
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
435 | "Received %d bytes for service\n", | 446 | "Received %d bytes for service\n", |
436 | fc->clientBufferDataLength); | 447 | fc->clientBufferDataLength); |
448 | #endif | ||
437 | if (fc->clientBufferDataLength <= 0) | 449 | if (fc->clientBufferDataLength <= 0) |
438 | { | 450 | { |
439 | /* The client has closed the connection or and error occured */ | 451 | /* The client has closed the connection or and error occured */ |
440 | if (fc->clientBufferDataLength == 0) | 452 | if (fc->clientBufferDataLength == 0) |
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 453 | { |
442 | _("Client closed connection with service:`%s'\n"), | 454 | #if DEBUG_SERVICE_MANAGER |
443 | fc->listen_info->serviceName); | 455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
456 | _("Client closed connection with service:`%s'\n"), | ||
457 | fc->listen_info->serviceName); | ||
458 | #endif | ||
459 | } | ||
444 | else | 460 | else |
445 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 461 | { |
446 | _("Error receiving from client: %s \n"), | 462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
447 | STRERROR (errno)); | 463 | _("Error receiving from client: %s \n"), |
464 | STRERROR (errno)); | ||
465 | } | ||
448 | closeClientAndServiceSockets (fc, REASON_CLIENT); | 466 | closeClientAndServiceSockets (fc, REASON_CLIENT); |
449 | return; | 467 | return; |
450 | } | 468 | } |
@@ -473,8 +491,10 @@ start_forwarding (void *cls, | |||
473 | (REASON_CLIENT & REASON_SERVICE)); | 491 | (REASON_CLIENT & REASON_SERVICE)); |
474 | return; | 492 | return; |
475 | } | 493 | } |
494 | #if DEBUG_SERVICE_MANAGER | ||
476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
477 | _("Connection to service to start forwarding\n")); | 496 | _("Connection to service to start forwarding\n")); |
497 | #endif | ||
478 | fc->armServiceSocket = | 498 | fc->armServiceSocket = |
479 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, | 499 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, |
480 | SOCK_STREAM, 0); | 500 | SOCK_STREAM, 0); |
@@ -526,20 +546,20 @@ connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
526 | { | 546 | { |
527 | struct ForwardedConnection *fc = cls; | 547 | struct ForwardedConnection *fc = cls; |
528 | 548 | ||
529 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 549 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
530 | { | 550 | { |
531 | /* Service is not up. Unable to proceed */ | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 551 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
533 | _("Unable to start service `%s': timeout\n"), | 552 | _("Unable to start service `%s': shutdown\n"), |
534 | fc->listen_info->serviceName); | 553 | fc->listen_info->serviceName); |
535 | closeClientAndServiceSockets (fc, | 554 | closeClientAndServiceSockets (fc, |
536 | (REASON_CLIENT & REASON_SERVICE)); | 555 | (REASON_CLIENT & REASON_SERVICE)); |
537 | return; | 556 | return; |
538 | } | 557 | } |
539 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 558 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
540 | { | 559 | { |
560 | /* Service is not up. Unable to proceed */ | ||
541 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 561 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
542 | _("Unable to start service `%s': shutdown\n"), | 562 | _("Unable to start service `%s': timeout\n"), |
543 | fc->listen_info->serviceName); | 563 | fc->listen_info->serviceName); |
544 | closeClientAndServiceSockets (fc, | 564 | closeClientAndServiceSockets (fc, |
545 | (REASON_CLIENT & REASON_SERVICE)); | 565 | (REASON_CLIENT & REASON_SERVICE)); |