diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-04 10:47:05 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-04 10:47:05 +0000 |
commit | 1947bc8ef4eb37738ffc1c566d9c6f96071b29f7 (patch) | |
tree | 881fd7b84296e59e9fbd30dabde297a501edc2ad /src/transport/plugin_transport_udp.c | |
parent | a317854b14a85a34f43655b1f74433c07f7ebbf9 (diff) | |
download | gnunet-1947bc8ef4eb37738ffc1c566d9c6f96071b29f7.tar.gz gnunet-1947bc8ef4eb37738ffc1c566d9c6f96071b29f7.zip |
- mem debug
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 122 |
1 files changed, 69 insertions, 53 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 52d4f6998..30fe1f1ea 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -442,8 +442,13 @@ struct Allocator | |||
442 | struct Allocator *next; | 442 | struct Allocator *next; |
443 | 443 | ||
444 | unsigned int bytes_alloced; | 444 | unsigned int bytes_alloced; |
445 | unsigned int max_alloced; | ||
445 | unsigned int diff; | 446 | unsigned int diff; |
446 | unsigned int line; | 447 | unsigned int line; |
448 | |||
449 | struct GNUNET_TIME_Absolute max_alloced_when; | ||
450 | struct GNUNET_TIME_Absolute last_alloced_when; | ||
451 | |||
447 | }; | 452 | }; |
448 | 453 | ||
449 | struct Allocator *aehead; | 454 | struct Allocator *aehead; |
@@ -487,17 +492,20 @@ print_allocators () | |||
487 | struct Allocator *cur = aehead; | 492 | struct Allocator *cur = aehead; |
488 | if (start) | 493 | if (start) |
489 | { | 494 | { |
490 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "INIT\n"); | ||
491 | next = GNUNET_TIME_UNIT_ZERO_ABS; | 495 | next = GNUNET_TIME_UNIT_ZERO_ABS; |
492 | start = GNUNET_NO; | 496 | start = GNUNET_NO; |
493 | } | 497 | } |
494 | if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value) | 498 | if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value) |
495 | { | 499 | { |
496 | fprintf (stderr, "Allocated in total: %5u bytes\n", bytes_alloced); | 500 | fprintf (stderr, "Allocated in `%s' total: %5u bytes\n", __FILE__, bytes_alloced); |
497 | while (NULL != cur) | 501 | while (NULL != cur) |
498 | { | 502 | { |
499 | 503 | char *last_alloc = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string(cur->max_alloced_when)); | |
500 | fprintf (stderr, "Allocated from line %4u :%5u bytes (diff %5i bytes)\n", cur->line, cur->bytes_alloced, cur->diff); | 504 | fprintf (stderr, "Allocated from line %4u :%5u bytes (diff %5i bytes, max alloc: %5u @ %s, last alloc %s)\n", |
505 | cur->line, cur->bytes_alloced, cur->diff, cur->max_alloced, | ||
506 | last_alloc, | ||
507 | GNUNET_STRINGS_absolute_time_to_string(cur->last_alloced_when)); | ||
508 | GNUNET_free (last_alloc); | ||
501 | cur->diff = 0; | 509 | cur->diff = 0; |
502 | cur = cur->next; | 510 | cur = cur->next; |
503 | } | 511 | } |
@@ -509,7 +517,7 @@ print_allocators () | |||
509 | #endif | 517 | #endif |
510 | 518 | ||
511 | static void | 519 | static void |
512 | UDP_add_alloc (void *p, size_t size, int line) | 520 | MEMDEBUG_add_alloc (void *p, size_t size, int line) |
513 | { | 521 | { |
514 | #if DEBUG_MALLOC | 522 | #if DEBUG_MALLOC |
515 | struct Allocation *alloc = GNUNET_malloc (sizeof (struct Allocation)); | 523 | struct Allocation *alloc = GNUNET_malloc (sizeof (struct Allocation)); |
@@ -525,6 +533,12 @@ UDP_add_alloc (void *p, size_t size, int line) | |||
525 | alloc->line = line; | 533 | alloc->line = line; |
526 | alloc->bytes_alloced = size; | 534 | alloc->bytes_alloced = size; |
527 | allocator->bytes_alloced += size; | 535 | allocator->bytes_alloced += size; |
536 | allocator->last_alloced_when = GNUNET_TIME_absolute_get(); | ||
537 | if (allocator->bytes_alloced >= allocator->max_alloced) | ||
538 | { | ||
539 | allocator->max_alloced = allocator->bytes_alloced; | ||
540 | allocator->max_alloced_when = allocator->last_alloced_when; | ||
541 | } | ||
528 | allocator->diff += size; | 542 | allocator->diff += size; |
529 | GNUNET_CONTAINER_DLL_insert (ahead, atail, alloc); | 543 | GNUNET_CONTAINER_DLL_insert (ahead, atail, alloc); |
530 | print_allocators (); | 544 | print_allocators (); |
@@ -534,21 +548,21 @@ UDP_add_alloc (void *p, size_t size, int line) | |||
534 | 548 | ||
535 | 549 | ||
536 | static void * | 550 | static void * |
537 | UDP_malloc (size_t size, int line) | 551 | MEMDEBUG_malloc (size_t size, int line) |
538 | { | 552 | { |
539 | void * ret; | 553 | void * ret; |
540 | 554 | ||
541 | ret = GNUNET_malloc (size); | 555 | ret = GNUNET_malloc (size); |
542 | #if DEBUG_MALLOC | 556 | #if DEBUG_MALLOC |
543 | if (NULL != ret) | 557 | if (NULL != ret) |
544 | UDP_add_alloc (ret, size, line); | 558 | MEMDEBUG_add_alloc (ret, size, line); |
545 | #endif | 559 | #endif |
546 | return ret; | 560 | return ret; |
547 | 561 | ||
548 | } | 562 | } |
549 | 563 | ||
550 | static void | 564 | static void |
551 | UDP_free (void * alloc, int line) | 565 | MEMDEBUG_free (void * alloc, int line) |
552 | { | 566 | { |
553 | #if DEBUG_MALLOC | 567 | #if DEBUG_MALLOC |
554 | struct Allocation *cur; | 568 | struct Allocation *cur; |
@@ -562,6 +576,7 @@ UDP_free (void * alloc, int line) | |||
562 | } | 576 | } |
563 | if (NULL == cur) | 577 | if (NULL == cur) |
564 | { | 578 | { |
579 | fprintf (stderr, "Unmonitored free from line %4u\n", line); | ||
565 | GNUNET_break (0); | 580 | GNUNET_break (0); |
566 | return; | 581 | return; |
567 | } | 582 | } |
@@ -582,10 +597,10 @@ UDP_free (void * alloc, int line) | |||
582 | } | 597 | } |
583 | 598 | ||
584 | static void | 599 | static void |
585 | UDP_free_non_null (void * alloc, int line) | 600 | MEMDEBUG_free_non_null (void * alloc, int line) |
586 | { | 601 | { |
587 | if (alloc != NULL) | 602 | if (alloc != NULL) |
588 | UDP_free (alloc, line); | 603 | MEMDEBUG_free (alloc, line); |
589 | } | 604 | } |
590 | 605 | ||
591 | 606 | ||
@@ -739,7 +754,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen, | |||
739 | { | 754 | { |
740 | struct IPv4UdpAddress *u4; | 755 | struct IPv4UdpAddress *u4; |
741 | struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address; | 756 | struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address; |
742 | u4 = UDP_malloc (sizeof (struct IPv4UdpAddress), __LINE__ ); | 757 | u4 = MEMDEBUG_malloc (sizeof (struct IPv4UdpAddress), __LINE__ ); |
743 | u4->ipv4_addr = in4->sin_addr.s_addr; | 758 | u4->ipv4_addr = in4->sin_addr.s_addr; |
744 | u4->u4_port = in4->sin_port; | 759 | u4->u4_port = in4->sin_port; |
745 | *buf = u4; | 760 | *buf = u4; |
@@ -750,7 +765,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen, | |||
750 | { | 765 | { |
751 | struct IPv6UdpAddress *u6; | 766 | struct IPv6UdpAddress *u6; |
752 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; | 767 | struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; |
753 | u6 = UDP_malloc (sizeof (struct IPv6UdpAddress), __LINE__ ); | 768 | u6 = MEMDEBUG_malloc (sizeof (struct IPv6UdpAddress), __LINE__ ); |
754 | u6->ipv6_addr = in6->sin6_addr; | 769 | u6->ipv6_addr = in6->sin6_addr; |
755 | u6->u6_port = in6->sin6_port; | 770 | u6->u6_port = in6->sin6_port; |
756 | *buf = u6; | 771 | *buf = u6; |
@@ -779,12 +794,13 @@ append_port (void *cls, const char *hostname) | |||
779 | if (hostname == NULL) | 794 | if (hostname == NULL) |
780 | { | 795 | { |
781 | ppc->asc (ppc->asc_cls, NULL); | 796 | ppc->asc (ppc->asc_cls, NULL); |
782 | UDP_free (ppc, __LINE__); | 797 | MEMDEBUG_free (ppc, __LINE__); |
783 | return; | 798 | return; |
784 | } | 799 | } |
785 | GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); | 800 | GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); |
801 | MEMDEBUG_add_alloc (ret, strlen (ret)+ 1, __LINE__); | ||
786 | ppc->asc (ppc->asc_cls, ret); | 802 | ppc->asc (ppc->asc_cls, ret); |
787 | UDP_free (ret, __LINE__); | 803 | MEMDEBUG_free (ret, __LINE__); |
788 | } | 804 | } |
789 | 805 | ||
790 | 806 | ||
@@ -860,7 +876,7 @@ udp_plugin_address_pretty_printer (void *cls, const char *type, | |||
860 | asc (asc_cls, NULL); | 876 | asc (asc_cls, NULL); |
861 | return; | 877 | return; |
862 | } | 878 | } |
863 | ppc = UDP_malloc (sizeof (struct PrettyPrinterContext), __LINE__ ); | 879 | ppc = MEMDEBUG_malloc (sizeof (struct PrettyPrinterContext), __LINE__ ); |
864 | ppc->asc = asc; | 880 | ppc->asc = asc; |
865 | ppc->asc_cls = asc_cls; | 881 | ppc->asc_cls = asc_cls; |
866 | ppc->port = port; | 882 | ppc->port = port; |
@@ -1124,10 +1140,10 @@ free_session (struct Session *s) | |||
1124 | if (NULL != s->frag_ctx) | 1140 | if (NULL != s->frag_ctx) |
1125 | { | 1141 | { |
1126 | GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL); | 1142 | GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL); |
1127 | UDP_free (s->frag_ctx, __LINE__); | 1143 | MEMDEBUG_free (s->frag_ctx, __LINE__); |
1128 | s->frag_ctx = NULL; | 1144 | s->frag_ctx = NULL; |
1129 | } | 1145 | } |
1130 | UDP_free (s, __LINE__); | 1146 | MEMDEBUG_free (s, __LINE__); |
1131 | } | 1147 | } |
1132 | 1148 | ||
1133 | 1149 | ||
@@ -1187,7 +1203,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1187 | { | 1203 | { |
1188 | dequeue (plugin, udpw); | 1204 | dequeue (plugin, udpw); |
1189 | call_continuation (udpw, GNUNET_SYSERR); | 1205 | call_continuation (udpw, GNUNET_SYSERR); |
1190 | UDP_free (udpw, __LINE__); | 1206 | MEMDEBUG_free (udpw, __LINE__); |
1191 | } | 1207 | } |
1192 | udpw = tmp; | 1208 | udpw = tmp; |
1193 | } | 1209 | } |
@@ -1202,7 +1218,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1202 | { | 1218 | { |
1203 | dequeue (plugin, udpw); | 1219 | dequeue (plugin, udpw); |
1204 | call_continuation (udpw, GNUNET_SYSERR); | 1220 | call_continuation (udpw, GNUNET_SYSERR); |
1205 | UDP_free (udpw, __LINE__); | 1221 | MEMDEBUG_free (udpw, __LINE__); |
1206 | } | 1222 | } |
1207 | udpw = tmp; | 1223 | udpw = tmp; |
1208 | } | 1224 | } |
@@ -1213,7 +1229,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1213 | &s->last_expected_msg_delay, | 1229 | &s->last_expected_msg_delay, |
1214 | &s->last_expected_ack_delay); | 1230 | &s->last_expected_ack_delay); |
1215 | s->frag_ctx = NULL; | 1231 | s->frag_ctx = NULL; |
1216 | UDP_free (fc , __LINE__); | 1232 | MEMDEBUG_free (fc , __LINE__); |
1217 | } | 1233 | } |
1218 | 1234 | ||
1219 | /** | 1235 | /** |
@@ -1251,7 +1267,7 @@ disconnect_session (struct Session *s) | |||
1251 | { | 1267 | { |
1252 | dequeue (plugin, udpw); | 1268 | dequeue (plugin, udpw); |
1253 | call_continuation(udpw, GNUNET_SYSERR); | 1269 | call_continuation(udpw, GNUNET_SYSERR); |
1254 | UDP_free (udpw, __LINE__); | 1270 | MEMDEBUG_free (udpw, __LINE__); |
1255 | } | 1271 | } |
1256 | } | 1272 | } |
1257 | next = plugin->ipv6_queue_head; | 1273 | next = plugin->ipv6_queue_head; |
@@ -1262,7 +1278,7 @@ disconnect_session (struct Session *s) | |||
1262 | { | 1278 | { |
1263 | dequeue (plugin, udpw); | 1279 | dequeue (plugin, udpw); |
1264 | call_continuation(udpw, GNUNET_SYSERR); | 1280 | call_continuation(udpw, GNUNET_SYSERR); |
1265 | UDP_free (udpw, __LINE__); | 1281 | MEMDEBUG_free (udpw, __LINE__); |
1266 | } | 1282 | } |
1267 | udpw = next; | 1283 | udpw = next; |
1268 | } | 1284 | } |
@@ -1424,7 +1440,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1424 | return NULL; | 1440 | return NULL; |
1425 | } | 1441 | } |
1426 | t4 = addr; | 1442 | t4 = addr; |
1427 | s = UDP_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in), __LINE__ ); | 1443 | s = MEMDEBUG_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in), __LINE__ ); |
1428 | len = sizeof (struct sockaddr_in); | 1444 | len = sizeof (struct sockaddr_in); |
1429 | v4 = (struct sockaddr_in *) &s[1]; | 1445 | v4 = (struct sockaddr_in *) &s[1]; |
1430 | v4->sin_family = AF_INET; | 1446 | v4->sin_family = AF_INET; |
@@ -1442,7 +1458,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1442 | } | 1458 | } |
1443 | t6 = addr; | 1459 | t6 = addr; |
1444 | s = | 1460 | s = |
1445 | UDP_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6), __LINE__ ); | 1461 | MEMDEBUG_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6), __LINE__ ); |
1446 | len = sizeof (struct sockaddr_in6); | 1462 | len = sizeof (struct sockaddr_in6); |
1447 | v6 = (struct sockaddr_in6 *) &s[1]; | 1463 | v6 = (struct sockaddr_in6 *) &s[1]; |
1448 | v6->sin6_family = AF_INET6; | 1464 | v6->sin6_family = AF_INET6; |
@@ -1665,7 +1681,7 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1665 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1681 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1666 | "Enqueuing fragment with %u bytes\n", msg_len); | 1682 | "Enqueuing fragment with %u bytes\n", msg_len); |
1667 | frag_ctx->fragments_used ++; | 1683 | frag_ctx->fragments_used ++; |
1668 | udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + msg_len, __LINE__ ); | 1684 | udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + msg_len, __LINE__ ); |
1669 | udpw->session = frag_ctx->session; | 1685 | udpw->session = frag_ctx->session; |
1670 | udpw->msg_buf = (char *) &udpw[1]; | 1686 | udpw->msg_buf = (char *) &udpw[1]; |
1671 | udpw->msg_size = msg_len; | 1687 | udpw->msg_size = msg_len; |
@@ -1757,7 +1773,7 @@ udp_plugin_send (void *cls, | |||
1757 | if (udpmlen <= UDP_MTU) | 1773 | if (udpmlen <= UDP_MTU) |
1758 | { | 1774 | { |
1759 | /* unfragmented message */ | 1775 | /* unfragmented message */ |
1760 | udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen, __LINE__ ); | 1776 | udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen, __LINE__ ); |
1761 | udpw->session = s; | 1777 | udpw->session = s; |
1762 | udpw->msg_buf = (char *) &udpw[1]; | 1778 | udpw->msg_buf = (char *) &udpw[1]; |
1763 | udpw->msg_size = udpmlen; /* message size with UDP overhead */ | 1779 | udpw->msg_size = udpmlen; /* message size with UDP overhead */ |
@@ -1784,7 +1800,7 @@ udp_plugin_send (void *cls, | |||
1784 | if (s->frag_ctx != NULL) | 1800 | if (s->frag_ctx != NULL) |
1785 | return GNUNET_SYSERR; | 1801 | return GNUNET_SYSERR; |
1786 | memcpy (&udp[1], msgbuf, msgbuf_size); | 1802 | memcpy (&udp[1], msgbuf, msgbuf_size); |
1787 | frag_ctx = UDP_malloc (sizeof (struct UDP_FragmentationContext), __LINE__ ); | 1803 | frag_ctx = MEMDEBUG_malloc (sizeof (struct UDP_FragmentationContext), __LINE__ ); |
1788 | frag_ctx->plugin = plugin; | 1804 | frag_ctx->plugin = plugin; |
1789 | frag_ctx->session = s; | 1805 | frag_ctx->session = s; |
1790 | frag_ctx->cont = cont; | 1806 | frag_ctx->cont = cont; |
@@ -1960,9 +1976,9 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1960 | GNUNET_a2s (sender_addr, sender_addr_len)); | 1976 | GNUNET_a2s (sender_addr, sender_addr_len)); |
1961 | 1977 | ||
1962 | struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); | 1978 | struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); |
1963 | UDP_add_alloc (address, GNUNET_HELLO_address_get_size(address), __LINE__); | 1979 | MEMDEBUG_add_alloc (address, GNUNET_HELLO_address_get_size(address), __LINE__); |
1964 | s = udp_plugin_get_session(plugin, address); | 1980 | s = udp_plugin_get_session(plugin, address); |
1965 | UDP_free (address, __LINE__); | 1981 | MEMDEBUG_free (address, __LINE__); |
1966 | 1982 | ||
1967 | /* iterate over all embedded messages */ | 1983 | /* iterate over all embedded messages */ |
1968 | si.session = s; | 1984 | si.session = s; |
@@ -2097,7 +2113,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
2097 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct | 2113 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct |
2098 | sockaddr_in6)), | 2114 | sockaddr_in6)), |
2099 | delay); | 2115 | delay); |
2100 | udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + msize, __LINE__ ); | 2116 | udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + msize, __LINE__ ); |
2101 | udpw->msg_size = msize; | 2117 | udpw->msg_size = msize; |
2102 | udpw->payload_size = 0; | 2118 | udpw->payload_size = 0; |
2103 | udpw->session = s; | 2119 | udpw->session = s; |
@@ -2226,7 +2242,7 @@ read_process_fragment (struct Plugin *plugin, | |||
2226 | if (d_ctx == NULL) | 2242 | if (d_ctx == NULL) |
2227 | { | 2243 | { |
2228 | /* Create a new defragmentation context */ | 2244 | /* Create a new defragmentation context */ |
2229 | d_ctx = UDP_malloc (sizeof (struct DefragContext) + fromlen, __LINE__ ); | 2245 | d_ctx = MEMDEBUG_malloc (sizeof (struct DefragContext) + fromlen, __LINE__ ); |
2230 | memcpy (&d_ctx[1], addr, fromlen); | 2246 | memcpy (&d_ctx[1], addr, fromlen); |
2231 | d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1]; | 2247 | d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1]; |
2232 | d_ctx->addr_len = fromlen; | 2248 | d_ctx->addr_len = fromlen; |
@@ -2266,7 +2282,7 @@ read_process_fragment (struct Plugin *plugin, | |||
2266 | d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs); | 2282 | d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs); |
2267 | GNUNET_assert (NULL != d_ctx); | 2283 | GNUNET_assert (NULL != d_ctx); |
2268 | GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag); | 2284 | GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag); |
2269 | UDP_free (d_ctx, __LINE__); | 2285 | MEMDEBUG_free (d_ctx, __LINE__); |
2270 | } | 2286 | } |
2271 | } | 2287 | } |
2272 | 2288 | ||
@@ -2397,7 +2413,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2397 | call_continuation (udpw, GNUNET_SYSERR); | 2413 | call_continuation (udpw, GNUNET_SYSERR); |
2398 | /* Remove message */ | 2414 | /* Remove message */ |
2399 | dequeue (plugin, udpw); | 2415 | dequeue (plugin, udpw); |
2400 | UDP_free (udpw, __LINE__); | 2416 | MEMDEBUG_free (udpw, __LINE__); |
2401 | break; | 2417 | break; |
2402 | case MSG_FRAGMENTED: | 2418 | case MSG_FRAGMENTED: |
2403 | /* Fragmented message */ | 2419 | /* Fragmented message */ |
@@ -2434,7 +2450,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, | |||
2434 | GNUNET_i2s(&udpw->session->target), udpw->payload_size); | 2450 | GNUNET_i2s(&udpw->session->target), udpw->payload_size); |
2435 | call_continuation (udpw, GNUNET_SYSERR); | 2451 | call_continuation (udpw, GNUNET_SYSERR); |
2436 | dequeue (plugin, udpw); | 2452 | dequeue (plugin, udpw); |
2437 | UDP_free (udpw, __LINE__); | 2453 | MEMDEBUG_free (udpw, __LINE__); |
2438 | break; | 2454 | break; |
2439 | default: | 2455 | default: |
2440 | break; | 2456 | break; |
@@ -2576,7 +2592,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
2576 | call_continuation (udpw, GNUNET_OK); | 2592 | call_continuation (udpw, GNUNET_OK); |
2577 | } | 2593 | } |
2578 | dequeue (plugin, udpw); | 2594 | dequeue (plugin, udpw); |
2579 | UDP_free (udpw, __LINE__); | 2595 | MEMDEBUG_free (udpw, __LINE__); |
2580 | udpw = NULL; | 2596 | udpw = NULL; |
2581 | 2597 | ||
2582 | return sent; | 2598 | return sent; |
@@ -2807,7 +2823,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2807 | { | 2823 | { |
2808 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | 2824 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully |
2809 | initialze the plugin or the API */ | 2825 | initialze the plugin or the API */ |
2810 | api = UDP_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ ); | 2826 | api = MEMDEBUG_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ ); |
2811 | api->cls = NULL; | 2827 | api->cls = NULL; |
2812 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | 2828 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; |
2813 | api->address_to_string = &udp_address_to_string; | 2829 | api->address_to_string = &udp_address_to_string; |
@@ -2857,7 +2873,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2857 | bind4_address); | 2873 | bind4_address); |
2858 | if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr)) | 2874 | if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr)) |
2859 | { | 2875 | { |
2860 | UDP_free (bind4_address, __LINE__); | 2876 | MEMDEBUG_free (bind4_address, __LINE__); |
2861 | return NULL; | 2877 | return NULL; |
2862 | } | 2878 | } |
2863 | } | 2879 | } |
@@ -2874,8 +2890,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2874 | { | 2890 | { |
2875 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), | 2891 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), |
2876 | bind6_address); | 2892 | bind6_address); |
2877 | UDP_free_non_null (bind4_address, __LINE__); | 2893 | MEMDEBUG_free_non_null (bind4_address, __LINE__); |
2878 | UDP_free (bind6_address, __LINE__); | 2894 | MEMDEBUG_free (bind6_address, __LINE__); |
2879 | return NULL; | 2895 | return NULL; |
2880 | } | 2896 | } |
2881 | } | 2897 | } |
@@ -2893,12 +2909,12 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2893 | } | 2909 | } |
2894 | else | 2910 | else |
2895 | { | 2911 | { |
2896 | UDP_add_alloc (fancy_interval, strlen (fancy_interval)+ 1, __LINE__); | 2912 | MEMDEBUG_add_alloc (fancy_interval, strlen (fancy_interval)+ 1, __LINE__); |
2897 | if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval)) | 2913 | if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval)) |
2898 | { | 2914 | { |
2899 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); | 2915 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); |
2900 | } | 2916 | } |
2901 | UDP_free (fancy_interval, __LINE__); | 2917 | MEMDEBUG_free (fancy_interval, __LINE__); |
2902 | } | 2918 | } |
2903 | 2919 | ||
2904 | /* Maximum datarate */ | 2920 | /* Maximum datarate */ |
@@ -2908,8 +2924,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2908 | udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ | 2924 | udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ |
2909 | } | 2925 | } |
2910 | 2926 | ||
2911 | p = UDP_malloc (sizeof (struct Plugin), __LINE__ ); | 2927 | p = MEMDEBUG_malloc (sizeof (struct Plugin), __LINE__ ); |
2912 | api = UDP_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ ); | 2928 | api = MEMDEBUG_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ ); |
2913 | 2929 | ||
2914 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, | 2930 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, |
2915 | GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); | 2931 | GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); |
@@ -2939,8 +2955,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2939 | if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL))) | 2955 | if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL))) |
2940 | { | 2956 | { |
2941 | LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create network sockets, plugin failed\n"); | 2957 | LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create network sockets, plugin failed\n"); |
2942 | UDP_free (p, __LINE__); | 2958 | MEMDEBUG_free (p, __LINE__); |
2943 | UDP_free (api, __LINE__); | 2959 | MEMDEBUG_free (api, __LINE__); |
2944 | return NULL; | 2960 | return NULL; |
2945 | } | 2961 | } |
2946 | 2962 | ||
@@ -2950,8 +2966,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2950 | setup_broadcast (p, &serverAddrv6, &serverAddrv4); | 2966 | setup_broadcast (p, &serverAddrv6, &serverAddrv4); |
2951 | } | 2967 | } |
2952 | 2968 | ||
2953 | UDP_free_non_null (bind4_address, __LINE__); | 2969 | MEMDEBUG_free_non_null (bind4_address, __LINE__); |
2954 | UDP_free_non_null (bind6_address, __LINE__); | 2970 | MEMDEBUG_free_non_null (bind6_address, __LINE__); |
2955 | return api; | 2971 | return api; |
2956 | } | 2972 | } |
2957 | 2973 | ||
@@ -2967,7 +2983,7 @@ heap_cleanup_iterator (void *cls, | |||
2967 | 2983 | ||
2968 | GNUNET_CONTAINER_heap_remove_node (node); | 2984 | GNUNET_CONTAINER_heap_remove_node (node); |
2969 | GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag); | 2985 | GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag); |
2970 | UDP_free (d_ctx, __LINE__); | 2986 | MEMDEBUG_free (d_ctx, __LINE__); |
2971 | 2987 | ||
2972 | return GNUNET_YES; | 2988 | return GNUNET_YES; |
2973 | } | 2989 | } |
@@ -2988,7 +3004,7 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2988 | 3004 | ||
2989 | if (NULL == plugin) | 3005 | if (NULL == plugin) |
2990 | { | 3006 | { |
2991 | UDP_free (api, __LINE__); | 3007 | MEMDEBUG_free (api, __LINE__); |
2992 | return NULL; | 3008 | return NULL; |
2993 | } | 3009 | } |
2994 | 3010 | ||
@@ -3045,7 +3061,7 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3045 | struct UDP_MessageWrapper *tmp = udpw->next; | 3061 | struct UDP_MessageWrapper *tmp = udpw->next; |
3046 | dequeue (plugin, udpw); | 3062 | dequeue (plugin, udpw); |
3047 | call_continuation(udpw, GNUNET_SYSERR); | 3063 | call_continuation(udpw, GNUNET_SYSERR); |
3048 | UDP_free (udpw, __LINE__); | 3064 | MEMDEBUG_free (udpw, __LINE__); |
3049 | 3065 | ||
3050 | udpw = tmp; | 3066 | udpw = tmp; |
3051 | } | 3067 | } |
@@ -3055,7 +3071,7 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3055 | struct UDP_MessageWrapper *tmp = udpw->next; | 3071 | struct UDP_MessageWrapper *tmp = udpw->next; |
3056 | dequeue (plugin, udpw); | 3072 | dequeue (plugin, udpw); |
3057 | call_continuation(udpw, GNUNET_SYSERR); | 3073 | call_continuation(udpw, GNUNET_SYSERR); |
3058 | UDP_free (udpw, __LINE__); | 3074 | MEMDEBUG_free (udpw, __LINE__); |
3059 | 3075 | ||
3060 | udpw = tmp; | 3076 | udpw = tmp; |
3061 | } | 3077 | } |
@@ -3067,8 +3083,8 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3067 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 3083 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); |
3068 | 3084 | ||
3069 | plugin->nat = NULL; | 3085 | plugin->nat = NULL; |
3070 | UDP_free (plugin, __LINE__); | 3086 | MEMDEBUG_free (plugin, __LINE__); |
3071 | UDP_free (api, __LINE__); | 3087 | MEMDEBUG_free (api, __LINE__); |
3072 | #if DEBUG_MALLOC | 3088 | #if DEBUG_MALLOC |
3073 | struct Allocation *allocation; | 3089 | struct Allocation *allocation; |
3074 | while (NULL != ahead) | 3090 | while (NULL != ahead) |