diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-26 13:35:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-26 13:35:28 +0000 |
commit | db7a7ef28e42cb253d5be3bde6ee580215f89f0a (patch) | |
tree | 6b8e959c34ea6f6b3131058e1dc1d27f8df995e7 /src/transport/plugin_transport_http_server.c | |
parent | 535d51c21e7ed8b8e1f9bec144c54f177de6b2f5 (diff) | |
download | gnunet-db7a7ef28e42cb253d5be3bde6ee580215f89f0a.tar.gz gnunet-db7a7ef28e42cb253d5be3bde6ee580215f89f0a.zip |
removing incoherent address formats
cleaning up logging
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 7776f1655..fd5df5097 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -270,6 +270,7 @@ static ssize_t | |||
270 | server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | 270 | server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) |
271 | { | 271 | { |
272 | struct Session *s = cls; | 272 | struct Session *s = cls; |
273 | struct Plugin *plugin = s->plugin; | ||
273 | struct HTTP_Message *msg; | 274 | struct HTTP_Message *msg; |
274 | int bytes_read = 0; | 275 | int bytes_read = 0; |
275 | //static int c = 0; | 276 | //static int c = 0; |
@@ -301,8 +302,9 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
301 | } | 302 | } |
302 | 303 | ||
303 | #if VERBOSE_CLIENT | 304 | #if VERBOSE_CLIENT |
304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u bytes\n", | 305 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
305 | s, bytes_read); | 306 | "Server: %X: sent %u bytes\n", |
307 | s, bytes_read); | ||
306 | #endif | 308 | #endif |
307 | return bytes_read; | 309 | return bytes_read; |
308 | } | 310 | } |
@@ -372,7 +374,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
372 | plugin->cur_connections++; | 374 | plugin->cur_connections++; |
373 | 375 | ||
374 | #if VERBOSE_SERVER | 376 | #if VERBOSE_SERVER |
375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag); | 377 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
378 | "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag); | ||
376 | #endif | 379 | #endif |
377 | /* find duplicate session */ | 380 | /* find duplicate session */ |
378 | 381 | ||
@@ -389,7 +392,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
389 | if (t != NULL) | 392 | if (t != NULL) |
390 | { | 393 | { |
391 | #if VERBOSE_SERVER | 394 | #if VERBOSE_SERVER |
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 395 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
396 | "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | ||
393 | #endif | 397 | #endif |
394 | goto error; | 398 | goto error; |
395 | } | 399 | } |
@@ -412,13 +416,15 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
412 | goto create; | 416 | goto create; |
413 | 417 | ||
414 | #if VERBOSE_SERVER | 418 | #if VERBOSE_SERVER |
415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target)); | 419 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
420 | "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target)); | ||
416 | #endif | 421 | #endif |
417 | 422 | ||
418 | if ((direction == _SEND) && (t->server_send != NULL)) | 423 | if ((direction == _SEND) && (t->server_send != NULL)) |
419 | { | 424 | { |
420 | #if VERBOSE_SERVER | 425 | #if VERBOSE_SERVER |
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 426 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
427 | "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | ||
422 | #endif | 428 | #endif |
423 | goto error; | 429 | goto error; |
424 | } | 430 | } |
@@ -428,7 +434,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
428 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); | 434 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); |
429 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); | 435 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); |
430 | #if VERBOSE_SERVER | 436 | #if VERBOSE_SERVER |
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | 437 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
438 | "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | ||
432 | #endif | 439 | #endif |
433 | 440 | ||
434 | goto found; | 441 | goto found; |
@@ -436,7 +443,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
436 | if ((direction == _RECEIVE) && (t->server_recv != NULL)) | 443 | if ((direction == _RECEIVE) && (t->server_recv != NULL)) |
437 | { | 444 | { |
438 | #if VERBOSE_SERVER | 445 | #if VERBOSE_SERVER |
439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | 446 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
447 | "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); | ||
440 | #endif | 448 | #endif |
441 | goto error; | 449 | goto error; |
442 | } | 450 | } |
@@ -446,7 +454,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
446 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); | 454 | GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); |
447 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); | 455 | GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); |
448 | #if VERBOSE_SERVER | 456 | #if VERBOSE_SERVER |
449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | 457 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
458 | "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); | ||
450 | #endif | 459 | #endif |
451 | goto found; | 460 | goto found; |
452 | } | 461 | } |
@@ -454,10 +463,11 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
454 | create: | 463 | create: |
455 | /* create new session */ | 464 | /* create new session */ |
456 | #if VERBOSE_SERVER | 465 | #if VERBOSE_SERVER |
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target)); | 466 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
467 | "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target)); | ||
458 | #endif | 468 | #endif |
459 | 469 | ||
460 | s = create_session(plugin, | 470 | s = create_session (plugin, |
461 | &target, | 471 | &target, |
462 | conn_info->client_addr, | 472 | conn_info->client_addr, |
463 | addrlen, | 473 | addrlen, |
@@ -474,7 +484,10 @@ create: | |||
474 | 484 | ||
475 | goto found; | 485 | goto found; |
476 | error: | 486 | error: |
477 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Invalid connection request\n"); | 487 | #if VERBOSE_SERVER |
488 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
489 | "Server: Invalid connection request\n"); | ||
490 | #endif | ||
478 | response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); | 491 | response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); |
479 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); | 492 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); |
480 | MHD_destroy_response (response); | 493 | MHD_destroy_response (response); |
@@ -490,8 +503,11 @@ found: | |||
490 | s->server_recv = sc; | 503 | s->server_recv = sc; |
491 | 504 | ||
492 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); | 505 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); |
493 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Setting Timeout to %u\n", to); | 506 | #if VERBOSE_SERVER |
494 | //MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); | 507 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
508 | "Server: Setting Timeout to %u\n", to); | ||
509 | #endif | ||
510 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); | ||
495 | 511 | ||
496 | (*httpSessionCache) = sc; | 512 | (*httpSessionCache) = sc; |
497 | } | 513 | } |
@@ -529,7 +545,7 @@ found: | |||
529 | { | 545 | { |
530 | #if VERBOSE_SERVER | 546 | #if VERBOSE_SERVER |
531 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 547 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
532 | "Server: peer `%s' PUT on address `%s' connected\n", | 548 | "Server: Peer `%s' PUT on address `%s' connected\n", |
533 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); | 549 | GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); |
534 | #endif | 550 | #endif |
535 | return MHD_YES; | 551 | return MHD_YES; |
@@ -545,17 +561,18 @@ found: | |||
545 | #endif | 561 | #endif |
546 | if ((GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)) | 562 | if ((GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)) |
547 | { | 563 | { |
548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 564 | #if VERBOSE_SERVER |
549 | "Connection %X: PUT with %u bytes forwarded to MST\n", s, | 565 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
566 | "Server: %X: PUT with %u bytes forwarded to MST\n", s, | ||
550 | *upload_data_size); | 567 | *upload_data_size); |
551 | 568 | #endif | |
552 | if (s->msg_tk == NULL) | 569 | if (s->msg_tk == NULL) |
553 | { | 570 | { |
554 | s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s); | 571 | s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s); |
555 | } | 572 | } |
556 | res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO); | 573 | res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO); |
557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 574 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
558 | "Server: Received %Zu bytes\n", | 575 | "Server: Received %Zu bytes\n", |
559 | *upload_data_size); | 576 | *upload_data_size); |
560 | (*upload_data_size) = 0; | 577 | (*upload_data_size) = 0; |
561 | } | 578 | } |
@@ -652,7 +669,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
652 | t = t->next; | 669 | t = t->next; |
653 | } | 670 | } |
654 | plugin->cur_connections--; | 671 | plugin->cur_connections--; |
655 | 672 | /* | |
656 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) | 673 | if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) |
657 | { | 674 | { |
658 | GNUNET_SCHEDULER_cancel(plugin->server_v4_task); | 675 | GNUNET_SCHEDULER_cancel(plugin->server_v4_task); |
@@ -666,7 +683,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
666 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; | 683 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; |
667 | } | 684 | } |
668 | plugin->server_v6_task = server_schedule (plugin, plugin->server_v6); | 685 | plugin->server_v6_task = server_schedule (plugin, plugin->server_v6); |
669 | 686 | */ | |
670 | if ((s->server_send == NULL) && (s->server_recv == NULL)) | 687 | if ((s->server_send == NULL) && (s->server_recv == NULL)) |
671 | { | 688 | { |
672 | #if VERBOSE_SERVER | 689 | #if VERBOSE_SERVER |