diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-02-02 14:41:20 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-02-02 14:41:20 +0000 |
commit | 241337d755d60b81311dd9cca4b4a32e0fb01b35 (patch) | |
tree | b0c49ad20acf6a29a5c26a934f973f7343097967 | |
parent | f761595401977b681f18bdb96f4cab0f3dcf1bc7 (diff) | |
download | gnunet-241337d755d60b81311dd9cca4b4a32e0fb01b35.tar.gz gnunet-241337d755d60b81311dd9cca4b4a32e0fb01b35.zip |
- Fixed MESH API logging behavior and code readability
-rw-r--r-- | src/mesh/mesh_api.c | 63 |
1 files changed, 22 insertions, 41 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 170572f13..d4c2e8155 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -636,11 +636,9 @@ send_connect (struct GNUNET_MESH_Handle *h) | |||
636 | types[ntypes] = htons (h->message_handlers[ntypes].type); | 636 | types[ntypes] = htons (h->message_handlers[ntypes].type); |
637 | msg->applications = htons (napps); | 637 | msg->applications = htons (napps); |
638 | msg->types = htons (ntypes); | 638 | msg->types = htons (ntypes); |
639 | #if MESH_API_DEBUG | ||
640 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 639 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
641 | "mesh: Sending %lu bytes long message %d types and %d apps\n", | 640 | "mesh: Sending %lu bytes long message %d types and %d apps\n", |
642 | ntohs (msg->header.size), ntypes, napps); | 641 | ntohs (msg->header.size), ntypes, napps); |
643 | #endif | ||
644 | send_packet (h, &msg->header, NULL); | 642 | send_packet (h, &msg->header, NULL); |
645 | } | 643 | } |
646 | } | 644 | } |
@@ -660,11 +658,10 @@ reconnect (struct GNUNET_MESH_Handle *h) | |||
660 | struct GNUNET_MESH_Tunnel *t; | 658 | struct GNUNET_MESH_Tunnel *t; |
661 | unsigned int i; | 659 | unsigned int i; |
662 | 660 | ||
663 | #if MESH_API_DEBUG | ||
664 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n"); | 661 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n"); |
665 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: ******* RECONNECT *******\n"); | 662 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: ******* RECONNECT *******\n"); |
666 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n"); | 663 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: *****************************\n"); |
667 | #endif | 664 | |
668 | h->in_receive = GNUNET_NO; | 665 | h->in_receive = GNUNET_NO; |
669 | /* disconnect */ | 666 | /* disconnect */ |
670 | if (NULL != h->th) | 667 | if (NULL != h->th) |
@@ -803,10 +800,7 @@ process_tunnel_created (struct GNUNET_MESH_Handle *h, | |||
803 | atsi.value = 0; | 800 | atsi.value = 0; |
804 | t->ctx = h->new_tunnel (h->cls, t, &msg->peer, &atsi); | 801 | t->ctx = h->new_tunnel (h->cls, t, &msg->peer, &atsi); |
805 | } | 802 | } |
806 | #if MESH_API_DEBUG | 803 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: new incoming tunnel %X\n", t->tid); |
807 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: new incoming tunnel %X\n", | ||
808 | t->tid); | ||
809 | #endif | ||
810 | return; | 804 | return; |
811 | } | 805 | } |
812 | 806 | ||
@@ -835,9 +829,7 @@ process_tunnel_destroy (struct GNUNET_MESH_Handle *h, | |||
835 | { | 829 | { |
836 | GNUNET_break (0); | 830 | GNUNET_break (0); |
837 | } | 831 | } |
838 | #if MESH_API_DEBUG | 832 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %u destroyed\n", t->tid); |
839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %u destroyed\n", t->tid); | ||
840 | #endif | ||
841 | destroy_tunnel (t, GNUNET_YES); | 833 | destroy_tunnel (t, GNUNET_YES); |
842 | return; | 834 | return; |
843 | } | 835 | } |
@@ -923,7 +915,7 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, | |||
923 | unsigned int i; | 915 | unsigned int i; |
924 | uint16_t type; | 916 | uint16_t type; |
925 | 917 | ||
926 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: Got a data message!\n"); | 918 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Got a data message!\n"); |
927 | type = ntohs (message->type); | 919 | type = ntohs (message->type); |
928 | switch (type) | 920 | switch (type) |
929 | { | 921 | { |
@@ -933,24 +925,24 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, | |||
933 | t = retrieve_tunnel (h, ntohl (ucast->tid)); | 925 | t = retrieve_tunnel (h, ntohl (ucast->tid)); |
934 | payload = (struct GNUNET_MessageHeader *) &ucast[1]; | 926 | payload = (struct GNUNET_MessageHeader *) &ucast[1]; |
935 | peer = &ucast->oid; | 927 | peer = &ucast->oid; |
936 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: ucast on tunnel %s [%x]\n", | 928 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: ucast on tunnel %s [%x]\n", |
937 | GNUNET_i2s (peer), ntohl (ucast->tid)); | 929 | GNUNET_i2s (peer), ntohl (ucast->tid)); |
938 | break; | 930 | break; |
939 | case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: | 931 | case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: |
940 | mcast = (struct GNUNET_MESH_Multicast *) message; | 932 | mcast = (struct GNUNET_MESH_Multicast *) message; |
941 | t = retrieve_tunnel (h, ntohl (mcast->tid)); | 933 | t = retrieve_tunnel (h, ntohl (mcast->tid)); |
942 | payload = (struct GNUNET_MessageHeader *) &mcast[1]; | 934 | payload = (struct GNUNET_MessageHeader *) &mcast[1]; |
943 | peer = &mcast->oid; | 935 | peer = &mcast->oid; |
944 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: mcast on tunnel %s [%x]\n", | 936 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: mcast on tunnel %s [%x]\n", |
945 | GNUNET_i2s (peer), ntohl (mcast->tid)); | 937 | GNUNET_i2s (peer), ntohl (mcast->tid)); |
946 | break; | 938 | break; |
947 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: | 939 | case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: |
948 | to_orig = (struct GNUNET_MESH_ToOrigin *) message; | 940 | to_orig = (struct GNUNET_MESH_ToOrigin *) message; |
949 | t = retrieve_tunnel (h, ntohl (to_orig->tid)); | 941 | t = retrieve_tunnel (h, ntohl (to_orig->tid)); |
950 | payload = (struct GNUNET_MessageHeader *) &to_orig[1]; | 942 | payload = (struct GNUNET_MessageHeader *) &to_orig[1]; |
951 | peer = &to_orig->sender; | 943 | peer = &to_orig->sender; |
952 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: torig on tunnel %s [%x]\n", | 944 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: torig on tunnel %s [%x]\n", |
953 | GNUNET_i2s (peer), ntohl (to_orig->tid)); | 945 | GNUNET_i2s (peer), ntohl (to_orig->tid)); |
954 | break; | 946 | break; |
955 | default: | 947 | default: |
956 | GNUNET_break (0); | 948 | GNUNET_break (0); |
@@ -978,14 +970,12 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, | |||
978 | GNUNET_MESH_disconnect (h); | 970 | GNUNET_MESH_disconnect (h); |
979 | return GNUNET_NO; | 971 | return GNUNET_NO; |
980 | } | 972 | } |
981 | #if MESH_API_DEBUG | ||
982 | else | 973 | else |
983 | { | 974 | { |
984 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 975 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
985 | "MESH: callback completed successfully\n"); | 976 | "MESH: callback completed successfully\n"); |
986 | 977 | ||
987 | } | 978 | } |
988 | #endif | ||
989 | } | 979 | } |
990 | } | 980 | } |
991 | return GNUNET_YES; | 981 | return GNUNET_YES; |
@@ -1088,8 +1078,8 @@ send_callback (void *cls, size_t size, void *buf) | |||
1088 | GNUNET_assert (size >= th->size); | 1078 | GNUNET_assert (size >= th->size); |
1089 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (to)]; | 1079 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (to)]; |
1090 | psize = th->notify (th->notify_cls, size - sizeof (to), mh); | 1080 | psize = th->notify (th->notify_cls, size - sizeof (to), mh); |
1091 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: to origin, type %u\n", | 1081 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: to origin, type %u\n", |
1092 | ntohs (mh->type)); | 1082 | ntohs (mh->type)); |
1093 | if (psize > 0) | 1083 | if (psize > 0) |
1094 | { | 1084 | { |
1095 | psize += sizeof (to); | 1085 | psize += sizeof (to); |
@@ -1111,8 +1101,8 @@ send_callback (void *cls, size_t size, void *buf) | |||
1111 | GNUNET_assert (size >= th->size); | 1101 | GNUNET_assert (size >= th->size); |
1112 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (mc)]; | 1102 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (mc)]; |
1113 | psize = th->notify (th->notify_cls, size - sizeof (mc), mh); | 1103 | psize = th->notify (th->notify_cls, size - sizeof (mc), mh); |
1114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: multicast, type %u\n", | 1104 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: multicast, type %u\n", |
1115 | ntohs (mh->type)); | 1105 | ntohs (mh->type)); |
1116 | if (psize > 0) | 1106 | if (psize > 0) |
1117 | { | 1107 | { |
1118 | psize += sizeof (mc); | 1108 | psize += sizeof (mc); |
@@ -1135,8 +1125,8 @@ send_callback (void *cls, size_t size, void *buf) | |||
1135 | GNUNET_assert (size >= th->size); | 1125 | GNUNET_assert (size >= th->size); |
1136 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (uc)]; | 1126 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (uc)]; |
1137 | psize = th->notify (th->notify_cls, size - sizeof (uc), mh); | 1127 | psize = th->notify (th->notify_cls, size - sizeof (uc), mh); |
1138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: unicast, type %u\n", | 1128 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: unicast, type %u\n", |
1139 | ntohs (mh->type)); | 1129 | ntohs (mh->type)); |
1140 | if (psize > 0) | 1130 | if (psize > 0) |
1141 | { | 1131 | { |
1142 | psize += sizeof (uc); | 1132 | psize += sizeof (uc); |
@@ -1309,10 +1299,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
1309 | if (t->tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 1299 | if (t->tid < GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) |
1310 | { | 1300 | { |
1311 | GNUNET_break (0); | 1301 | GNUNET_break (0); |
1312 | #if MESH_API_DEBUG | 1302 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %X not destroyed\n", t->tid); |
1313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %X not destroyed\n", | ||
1314 | t->tid); | ||
1315 | #endif | ||
1316 | } | 1303 | } |
1317 | destroy_tunnel (t, GNUNET_YES); | 1304 | destroy_tunnel (t, GNUNET_YES); |
1318 | t = aux; | 1305 | t = aux; |
@@ -1334,10 +1321,8 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
1334 | break; | 1321 | break; |
1335 | default: | 1322 | default: |
1336 | GNUNET_break (0); | 1323 | GNUNET_break (0); |
1337 | #if MESH_API_DEBUG | 1324 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: unexpected msg %u\n", |
1338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: unexpected msg %u\n", | 1325 | ntohs(msg->type)); |
1339 | ntohs(msg->type)); | ||
1340 | #endif | ||
1341 | } | 1326 | } |
1342 | 1327 | ||
1343 | GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th); | 1328 | GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th); |
@@ -1579,15 +1564,11 @@ GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, | |||
1579 | size_t overhead; | 1564 | size_t overhead; |
1580 | 1565 | ||
1581 | GNUNET_assert (NULL != tunnel); | 1566 | GNUNET_assert (NULL != tunnel); |
1582 | #if MESH_API_DEBUG | 1567 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: mesh notify transmit ready called\n"); |
1583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1584 | "mesh: mesh notify transmit ready called\n"); | ||
1585 | if (NULL != target) | 1568 | if (NULL != target) |
1586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: target %s\n", | 1569 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: target %s\n", GNUNET_i2s (target)); |
1587 | GNUNET_i2s (target)); | ||
1588 | else | 1570 | else |
1589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: target multicast\n"); | 1571 | LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: target multicast\n"); |
1590 | #endif | ||
1591 | GNUNET_assert (NULL != notify); | 1572 | GNUNET_assert (NULL != notify); |
1592 | if (tunnel->mesh->npackets >= tunnel->mesh->max_queue_size && | 1573 | if (tunnel->mesh->npackets >= tunnel->mesh->max_queue_size && |
1593 | tunnel->npackets > 0) | 1574 | tunnel->npackets > 0) |