aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_udp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-30 12:30:49 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-30 12:30:49 +0000
commit82192554226a3bb4be6487caf0df354b2e71da99 (patch)
tree7bba440930ce3835ab80a5c29f58c08499562978 /src/transport/plugin_transport_udp.c
parent567249dc588769a74fbcbbb2a7b1042b3ebeb5d2 (diff)
downloadgnunet-82192554226a3bb4be6487caf0df354b2e71da99.tar.gz
gnunet-82192554226a3bb4be6487caf0df354b2e71da99.zip
- mem leak debugging: monitor allocations in udp
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r--src/transport/plugin_transport_udp.c255
1 files changed, 214 insertions, 41 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 5396a4bf4..52d4f6998 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -63,6 +63,7 @@
63#define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 63#define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128
64 64
65 65
66#define DEBUG_MALLOC GNUNET_NO
66 67
67/** 68/**
68 * Closure for 'append_port'. 69 * Closure for 'append_port'.
@@ -433,6 +434,160 @@ reschedule_session_timeout (struct Session *s);
433static void 434static void
434stop_session_timeout (struct Session *s); 435stop_session_timeout (struct Session *s);
435 436
437#if DEBUG_MALLOC
438
439struct Allocator
440{
441 struct Allocator *prev;
442 struct Allocator *next;
443
444 unsigned int bytes_alloced;
445 unsigned int diff;
446 unsigned int line;
447};
448
449struct Allocator *aehead;
450struct Allocator *aetail;
451
452struct Allocation
453{
454 struct Allocation *prev;
455 struct Allocation *next;
456
457 struct Allocator *alloc;
458 unsigned int bytes_alloced;
459 void *p;
460 unsigned int line;
461};
462
463struct Allocation *ahead;
464struct Allocation *atail;
465
466static int bytes_alloced;
467
468static struct Allocator *
469find_allocator (int line)
470{
471 struct Allocator *cur = aehead;
472 while (NULL != cur)
473 {
474 if (line == cur->line)
475 return cur;
476 cur = cur->next;
477 }
478 return cur;
479}
480
481static void
482print_allocators ()
483{
484 static int start = GNUNET_YES;
485 static struct GNUNET_TIME_Absolute next;
486 static struct GNUNET_TIME_Relative rem;
487 struct Allocator *cur = aehead;
488 if (start)
489 {
490 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "INIT\n");
491 next = GNUNET_TIME_UNIT_ZERO_ABS;
492 start = GNUNET_NO;
493 }
494 if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value)
495 {
496 fprintf (stderr, "Allocated in total: %5u bytes\n", bytes_alloced);
497 while (NULL != cur)
498 {
499
500 fprintf (stderr, "Allocated from line %4u :%5u bytes (diff %5i bytes)\n", cur->line, cur->bytes_alloced, cur->diff);
501 cur->diff = 0;
502 cur = cur->next;
503 }
504 fprintf (stderr, "\n");
505 next = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_SECONDS);
506 }
507}
508
509#endif
510
511static void
512UDP_add_alloc (void *p, size_t size, int line)
513{
514#if DEBUG_MALLOC
515 struct Allocation *alloc = GNUNET_malloc (sizeof (struct Allocation));
516 struct Allocator *allocator = find_allocator(line);
517 if (NULL == allocator)
518 {
519 allocator = GNUNET_malloc (sizeof (struct Allocator));
520 allocator->line = line;
521 GNUNET_CONTAINER_DLL_insert (aehead, aetail, allocator);
522 }
523 alloc->alloc = allocator;
524 alloc->p = p;
525 alloc->line = line;
526 alloc->bytes_alloced = size;
527 allocator->bytes_alloced += size;
528 allocator->diff += size;
529 GNUNET_CONTAINER_DLL_insert (ahead, atail, alloc);
530 print_allocators ();
531 bytes_alloced += size;
532#endif
533}
534
535
536static void *
537UDP_malloc (size_t size, int line)
538{
539 void * ret;
540
541 ret = GNUNET_malloc (size);
542#if DEBUG_MALLOC
543 if (NULL != ret)
544 UDP_add_alloc (ret, size, line);
545#endif
546 return ret;
547
548}
549
550static void
551UDP_free (void * alloc, int line)
552{
553#if DEBUG_MALLOC
554 struct Allocation *cur;
555 struct Allocator *allocator;
556 cur = ahead;
557 while (NULL != cur)
558 {
559 if (alloc == cur->p)
560 break;
561 cur = cur->next;
562 }
563 if (NULL == cur)
564 {
565 GNUNET_break (0);
566 return;
567 }
568 allocator = cur->alloc;
569 if (NULL == allocator)
570 {
571 GNUNET_break (0);
572 }
573 GNUNET_CONTAINER_DLL_remove (ahead, atail, cur);
574 allocator->bytes_alloced -= cur->bytes_alloced;
575 allocator->diff -= cur->bytes_alloced;
576 GNUNET_assert (allocator->bytes_alloced >= 0);
577 bytes_alloced -= cur->bytes_alloced;
578 GNUNET_assert (bytes_alloced >= 0);
579 GNUNET_free (cur);
580#endif
581 GNUNET_free (alloc);
582}
583
584static void
585UDP_free_non_null (void * alloc, int line)
586{
587 if (alloc != NULL)
588 UDP_free (alloc, line);
589}
590
436 591
437/** 592/**
438 * (re)schedule select tasks for this plugin. 593 * (re)schedule select tasks for this plugin.
@@ -584,7 +739,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
584 { 739 {
585 struct IPv4UdpAddress *u4; 740 struct IPv4UdpAddress *u4;
586 struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address; 741 struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address;
587 u4 = GNUNET_malloc (sizeof (struct IPv4UdpAddress)); 742 u4 = UDP_malloc (sizeof (struct IPv4UdpAddress), __LINE__ );
588 u4->ipv4_addr = in4->sin_addr.s_addr; 743 u4->ipv4_addr = in4->sin_addr.s_addr;
589 u4->u4_port = in4->sin_port; 744 u4->u4_port = in4->sin_port;
590 *buf = u4; 745 *buf = u4;
@@ -595,7 +750,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
595 { 750 {
596 struct IPv6UdpAddress *u6; 751 struct IPv6UdpAddress *u6;
597 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; 752 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
598 u6 = GNUNET_malloc (sizeof (struct IPv6UdpAddress)); 753 u6 = UDP_malloc (sizeof (struct IPv6UdpAddress), __LINE__ );
599 u6->ipv6_addr = in6->sin6_addr; 754 u6->ipv6_addr = in6->sin6_addr;
600 u6->u6_port = in6->sin6_port; 755 u6->u6_port = in6->sin6_port;
601 *buf = u6; 756 *buf = u6;
@@ -624,12 +779,12 @@ append_port (void *cls, const char *hostname)
624 if (hostname == NULL) 779 if (hostname == NULL)
625 { 780 {
626 ppc->asc (ppc->asc_cls, NULL); 781 ppc->asc (ppc->asc_cls, NULL);
627 GNUNET_free (ppc); 782 UDP_free (ppc, __LINE__);
628 return; 783 return;
629 } 784 }
630 GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); 785 GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port);
631 ppc->asc (ppc->asc_cls, ret); 786 ppc->asc (ppc->asc_cls, ret);
632 GNUNET_free (ret); 787 UDP_free (ret, __LINE__);
633} 788}
634 789
635 790
@@ -705,7 +860,7 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
705 asc (asc_cls, NULL); 860 asc (asc_cls, NULL);
706 return; 861 return;
707 } 862 }
708 ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext)); 863 ppc = UDP_malloc (sizeof (struct PrettyPrinterContext), __LINE__ );
709 ppc->asc = asc; 864 ppc->asc = asc;
710 ppc->asc_cls = asc_cls; 865 ppc->asc_cls = asc_cls;
711 ppc->port = port; 866 ppc->port = port;
@@ -969,10 +1124,10 @@ free_session (struct Session *s)
969 if (NULL != s->frag_ctx) 1124 if (NULL != s->frag_ctx)
970 { 1125 {
971 GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL); 1126 GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL);
972 GNUNET_free (s->frag_ctx); 1127 UDP_free (s->frag_ctx, __LINE__);
973 s->frag_ctx = NULL; 1128 s->frag_ctx = NULL;
974 } 1129 }
975 GNUNET_free (s); 1130 UDP_free (s, __LINE__);
976} 1131}
977 1132
978 1133
@@ -1032,7 +1187,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1032 { 1187 {
1033 dequeue (plugin, udpw); 1188 dequeue (plugin, udpw);
1034 call_continuation (udpw, GNUNET_SYSERR); 1189 call_continuation (udpw, GNUNET_SYSERR);
1035 GNUNET_free (udpw); 1190 UDP_free (udpw, __LINE__);
1036 } 1191 }
1037 udpw = tmp; 1192 udpw = tmp;
1038 } 1193 }
@@ -1047,7 +1202,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1047 { 1202 {
1048 dequeue (plugin, udpw); 1203 dequeue (plugin, udpw);
1049 call_continuation (udpw, GNUNET_SYSERR); 1204 call_continuation (udpw, GNUNET_SYSERR);
1050 GNUNET_free (udpw); 1205 UDP_free (udpw, __LINE__);
1051 } 1206 }
1052 udpw = tmp; 1207 udpw = tmp;
1053 } 1208 }
@@ -1058,7 +1213,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1058 &s->last_expected_msg_delay, 1213 &s->last_expected_msg_delay,
1059 &s->last_expected_ack_delay); 1214 &s->last_expected_ack_delay);
1060 s->frag_ctx = NULL; 1215 s->frag_ctx = NULL;
1061 GNUNET_free (fc); 1216 UDP_free (fc , __LINE__);
1062} 1217}
1063 1218
1064/** 1219/**
@@ -1096,7 +1251,7 @@ disconnect_session (struct Session *s)
1096 { 1251 {
1097 dequeue (plugin, udpw); 1252 dequeue (plugin, udpw);
1098 call_continuation(udpw, GNUNET_SYSERR); 1253 call_continuation(udpw, GNUNET_SYSERR);
1099 GNUNET_free (udpw); 1254 UDP_free (udpw, __LINE__);
1100 } 1255 }
1101 } 1256 }
1102 next = plugin->ipv6_queue_head; 1257 next = plugin->ipv6_queue_head;
@@ -1107,7 +1262,7 @@ disconnect_session (struct Session *s)
1107 { 1262 {
1108 dequeue (plugin, udpw); 1263 dequeue (plugin, udpw);
1109 call_continuation(udpw, GNUNET_SYSERR); 1264 call_continuation(udpw, GNUNET_SYSERR);
1110 GNUNET_free (udpw); 1265 UDP_free (udpw, __LINE__);
1111 } 1266 }
1112 udpw = next; 1267 udpw = next;
1113 } 1268 }
@@ -1269,7 +1424,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
1269 return NULL; 1424 return NULL;
1270 } 1425 }
1271 t4 = addr; 1426 t4 = addr;
1272 s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); 1427 s = UDP_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in), __LINE__ );
1273 len = sizeof (struct sockaddr_in); 1428 len = sizeof (struct sockaddr_in);
1274 v4 = (struct sockaddr_in *) &s[1]; 1429 v4 = (struct sockaddr_in *) &s[1];
1275 v4->sin_family = AF_INET; 1430 v4->sin_family = AF_INET;
@@ -1287,7 +1442,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
1287 } 1442 }
1288 t6 = addr; 1443 t6 = addr;
1289 s = 1444 s =
1290 GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); 1445 UDP_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6), __LINE__ );
1291 len = sizeof (struct sockaddr_in6); 1446 len = sizeof (struct sockaddr_in6);
1292 v6 = (struct sockaddr_in6 *) &s[1]; 1447 v6 = (struct sockaddr_in6 *) &s[1];
1293 v6->sin6_family = AF_INET6; 1448 v6->sin6_family = AF_INET6;
@@ -1510,7 +1665,7 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
1510 LOG (GNUNET_ERROR_TYPE_DEBUG, 1665 LOG (GNUNET_ERROR_TYPE_DEBUG,
1511 "Enqueuing fragment with %u bytes\n", msg_len); 1666 "Enqueuing fragment with %u bytes\n", msg_len);
1512 frag_ctx->fragments_used ++; 1667 frag_ctx->fragments_used ++;
1513 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); 1668 udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + msg_len, __LINE__ );
1514 udpw->session = frag_ctx->session; 1669 udpw->session = frag_ctx->session;
1515 udpw->msg_buf = (char *) &udpw[1]; 1670 udpw->msg_buf = (char *) &udpw[1];
1516 udpw->msg_size = msg_len; 1671 udpw->msg_size = msg_len;
@@ -1602,7 +1757,7 @@ udp_plugin_send (void *cls,
1602 if (udpmlen <= UDP_MTU) 1757 if (udpmlen <= UDP_MTU)
1603 { 1758 {
1604 /* unfragmented message */ 1759 /* unfragmented message */
1605 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen); 1760 udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen, __LINE__ );
1606 udpw->session = s; 1761 udpw->session = s;
1607 udpw->msg_buf = (char *) &udpw[1]; 1762 udpw->msg_buf = (char *) &udpw[1];
1608 udpw->msg_size = udpmlen; /* message size with UDP overhead */ 1763 udpw->msg_size = udpmlen; /* message size with UDP overhead */
@@ -1629,7 +1784,7 @@ udp_plugin_send (void *cls,
1629 if (s->frag_ctx != NULL) 1784 if (s->frag_ctx != NULL)
1630 return GNUNET_SYSERR; 1785 return GNUNET_SYSERR;
1631 memcpy (&udp[1], msgbuf, msgbuf_size); 1786 memcpy (&udp[1], msgbuf, msgbuf_size);
1632 frag_ctx = GNUNET_malloc (sizeof (struct UDP_FragmentationContext)); 1787 frag_ctx = UDP_malloc (sizeof (struct UDP_FragmentationContext), __LINE__ );
1633 frag_ctx->plugin = plugin; 1788 frag_ctx->plugin = plugin;
1634 frag_ctx->session = s; 1789 frag_ctx->session = s;
1635 frag_ctx->cont = cont; 1790 frag_ctx->cont = cont;
@@ -1805,8 +1960,9 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg,
1805 GNUNET_a2s (sender_addr, sender_addr_len)); 1960 GNUNET_a2s (sender_addr, sender_addr_len));
1806 1961
1807 struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); 1962 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__);
1808 s = udp_plugin_get_session(plugin, address); 1964 s = udp_plugin_get_session(plugin, address);
1809 GNUNET_free (address); 1965 UDP_free (address, __LINE__);
1810 1966
1811 /* iterate over all embedded messages */ 1967 /* iterate over all embedded messages */
1812 si.session = s; 1968 si.session = s;
@@ -1941,7 +2097,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
1941 AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct 2097 AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct
1942 sockaddr_in6)), 2098 sockaddr_in6)),
1943 delay); 2099 delay);
1944 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); 2100 udpw = UDP_malloc (sizeof (struct UDP_MessageWrapper) + msize, __LINE__ );
1945 udpw->msg_size = msize; 2101 udpw->msg_size = msize;
1946 udpw->payload_size = 0; 2102 udpw->payload_size = 0;
1947 udpw->session = s; 2103 udpw->session = s;
@@ -2070,7 +2226,7 @@ read_process_fragment (struct Plugin *plugin,
2070 if (d_ctx == NULL) 2226 if (d_ctx == NULL)
2071 { 2227 {
2072 /* Create a new defragmentation context */ 2228 /* Create a new defragmentation context */
2073 d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + fromlen); 2229 d_ctx = UDP_malloc (sizeof (struct DefragContext) + fromlen, __LINE__ );
2074 memcpy (&d_ctx[1], addr, fromlen); 2230 memcpy (&d_ctx[1], addr, fromlen);
2075 d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1]; 2231 d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1];
2076 d_ctx->addr_len = fromlen; 2232 d_ctx->addr_len = fromlen;
@@ -2110,7 +2266,7 @@ read_process_fragment (struct Plugin *plugin,
2110 d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs); 2266 d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs);
2111 GNUNET_assert (NULL != d_ctx); 2267 GNUNET_assert (NULL != d_ctx);
2112 GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag); 2268 GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag);
2113 GNUNET_free (d_ctx); 2269 UDP_free (d_ctx, __LINE__);
2114 } 2270 }
2115} 2271}
2116 2272
@@ -2241,7 +2397,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2241 call_continuation (udpw, GNUNET_SYSERR); 2397 call_continuation (udpw, GNUNET_SYSERR);
2242 /* Remove message */ 2398 /* Remove message */
2243 dequeue (plugin, udpw); 2399 dequeue (plugin, udpw);
2244 GNUNET_free (udpw); 2400 UDP_free (udpw, __LINE__);
2245 break; 2401 break;
2246 case MSG_FRAGMENTED: 2402 case MSG_FRAGMENTED:
2247 /* Fragmented message */ 2403 /* Fragmented message */
@@ -2278,7 +2434,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2278 GNUNET_i2s(&udpw->session->target), udpw->payload_size); 2434 GNUNET_i2s(&udpw->session->target), udpw->payload_size);
2279 call_continuation (udpw, GNUNET_SYSERR); 2435 call_continuation (udpw, GNUNET_SYSERR);
2280 dequeue (plugin, udpw); 2436 dequeue (plugin, udpw);
2281 GNUNET_free (udpw); 2437 UDP_free (udpw, __LINE__);
2282 break; 2438 break;
2283 default: 2439 default:
2284 break; 2440 break;
@@ -2420,7 +2576,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
2420 call_continuation (udpw, GNUNET_OK); 2576 call_continuation (udpw, GNUNET_OK);
2421 } 2577 }
2422 dequeue (plugin, udpw); 2578 dequeue (plugin, udpw);
2423 GNUNET_free (udpw); 2579 UDP_free (udpw, __LINE__);
2424 udpw = NULL; 2580 udpw = NULL;
2425 2581
2426 return sent; 2582 return sent;
@@ -2651,7 +2807,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2651 { 2807 {
2652 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully 2808 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
2653 initialze the plugin or the API */ 2809 initialze the plugin or the API */
2654 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 2810 api = UDP_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ );
2655 api->cls = NULL; 2811 api->cls = NULL;
2656 api->address_pretty_printer = &udp_plugin_address_pretty_printer; 2812 api->address_pretty_printer = &udp_plugin_address_pretty_printer;
2657 api->address_to_string = &udp_address_to_string; 2813 api->address_to_string = &udp_address_to_string;
@@ -2701,7 +2857,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2701 bind4_address); 2857 bind4_address);
2702 if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr)) 2858 if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr))
2703 { 2859 {
2704 GNUNET_free (bind4_address); 2860 UDP_free (bind4_address, __LINE__);
2705 return NULL; 2861 return NULL;
2706 } 2862 }
2707 } 2863 }
@@ -2718,8 +2874,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2718 { 2874 {
2719 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), 2875 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"),
2720 bind6_address); 2876 bind6_address);
2721 GNUNET_free_non_null (bind4_address); 2877 UDP_free_non_null (bind4_address, __LINE__);
2722 GNUNET_free (bind6_address); 2878 UDP_free (bind6_address, __LINE__);
2723 return NULL; 2879 return NULL;
2724 } 2880 }
2725 } 2881 }
@@ -2737,11 +2893,12 @@ libgnunet_plugin_transport_udp_init (void *cls)
2737 } 2893 }
2738 else 2894 else
2739 { 2895 {
2896 UDP_add_alloc (fancy_interval, strlen (fancy_interval)+ 1, __LINE__);
2740 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval)) 2897 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval))
2741 { 2898 {
2742 interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); 2899 interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
2743 } 2900 }
2744 GNUNET_free (fancy_interval); 2901 UDP_free (fancy_interval, __LINE__);
2745 } 2902 }
2746 2903
2747 /* Maximum datarate */ 2904 /* Maximum datarate */
@@ -2751,8 +2908,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2751 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ 2908 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */
2752 } 2909 }
2753 2910
2754 p = GNUNET_malloc (sizeof (struct Plugin)); 2911 p = UDP_malloc (sizeof (struct Plugin), __LINE__ );
2755 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 2912 api = UDP_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ );
2756 2913
2757 GNUNET_BANDWIDTH_tracker_init (&p->tracker, 2914 GNUNET_BANDWIDTH_tracker_init (&p->tracker,
2758 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); 2915 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30);
@@ -2782,8 +2939,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2782 if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL))) 2939 if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL)))
2783 { 2940 {
2784 LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create network sockets, plugin failed\n"); 2941 LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create network sockets, plugin failed\n");
2785 GNUNET_free (p); 2942 UDP_free (p, __LINE__);
2786 GNUNET_free (api); 2943 UDP_free (api, __LINE__);
2787 return NULL; 2944 return NULL;
2788 } 2945 }
2789 2946
@@ -2793,8 +2950,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2793 setup_broadcast (p, &serverAddrv6, &serverAddrv4); 2950 setup_broadcast (p, &serverAddrv6, &serverAddrv4);
2794 } 2951 }
2795 2952
2796 GNUNET_free_non_null (bind4_address); 2953 UDP_free_non_null (bind4_address, __LINE__);
2797 GNUNET_free_non_null (bind6_address); 2954 UDP_free_non_null (bind6_address, __LINE__);
2798 return api; 2955 return api;
2799} 2956}
2800 2957
@@ -2810,7 +2967,7 @@ heap_cleanup_iterator (void *cls,
2810 2967
2811 GNUNET_CONTAINER_heap_remove_node (node); 2968 GNUNET_CONTAINER_heap_remove_node (node);
2812 GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag); 2969 GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag);
2813 GNUNET_free (d_ctx); 2970 UDP_free (d_ctx, __LINE__);
2814 2971
2815 return GNUNET_YES; 2972 return GNUNET_YES;
2816} 2973}
@@ -2831,7 +2988,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
2831 2988
2832 if (NULL == plugin) 2989 if (NULL == plugin)
2833 { 2990 {
2834 GNUNET_free (api); 2991 UDP_free (api, __LINE__);
2835 return NULL; 2992 return NULL;
2836 } 2993 }
2837 2994
@@ -2888,7 +3045,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
2888 struct UDP_MessageWrapper *tmp = udpw->next; 3045 struct UDP_MessageWrapper *tmp = udpw->next;
2889 dequeue (plugin, udpw); 3046 dequeue (plugin, udpw);
2890 call_continuation(udpw, GNUNET_SYSERR); 3047 call_continuation(udpw, GNUNET_SYSERR);
2891 GNUNET_free (udpw); 3048 UDP_free (udpw, __LINE__);
2892 3049
2893 udpw = tmp; 3050 udpw = tmp;
2894 } 3051 }
@@ -2898,7 +3055,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
2898 struct UDP_MessageWrapper *tmp = udpw->next; 3055 struct UDP_MessageWrapper *tmp = udpw->next;
2899 dequeue (plugin, udpw); 3056 dequeue (plugin, udpw);
2900 call_continuation(udpw, GNUNET_SYSERR); 3057 call_continuation(udpw, GNUNET_SYSERR);
2901 GNUNET_free (udpw); 3058 UDP_free (udpw, __LINE__);
2902 3059
2903 udpw = tmp; 3060 udpw = tmp;
2904 } 3061 }
@@ -2910,8 +3067,24 @@ libgnunet_plugin_transport_udp_done (void *cls)
2910 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); 3067 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions);
2911 3068
2912 plugin->nat = NULL; 3069 plugin->nat = NULL;
2913 GNUNET_free (plugin); 3070 UDP_free (plugin, __LINE__);
2914 GNUNET_free (api); 3071 UDP_free (api, __LINE__);
3072#if DEBUG_MALLOC
3073 struct Allocation *allocation;
3074 while (NULL != ahead)
3075 {
3076 allocation = ahead;
3077 GNUNET_CONTAINER_DLL_remove (ahead, atail, allocation);
3078 GNUNET_free (allocation);
3079 }
3080 struct Allocator *allocator;
3081 while (NULL != aehead)
3082 {
3083 allocator = aehead;
3084 GNUNET_CONTAINER_DLL_remove (aehead, aetail, allocator);
3085 GNUNET_free (allocator);
3086 }
3087#endif
2915 return NULL; 3088 return NULL;
2916} 3089}
2917 3090