aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/gnunet-communicator-tcp.c137
-rw-r--r--src/transport/test_communicator_basic.c24
-rw-r--r--src/transport/test_communicator_unix_basic_peer1.conf2
-rw-r--r--src/transport/test_communicator_unix_basic_peer2.conf2
-rw-r--r--src/transport/transport-testing2.c144
-rw-r--r--src/transport/transport-testing2.h144
-rw-r--r--src/util/mq.c6
7 files changed, 269 insertions, 190 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 4caef909c..59f42496a 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -394,11 +394,6 @@ struct Queue
394 struct GNUNET_PeerIdentity target; 394 struct GNUNET_PeerIdentity target;
395 395
396 /** 396 /**
397 * ID of listen task
398 */
399 struct GNUNET_SCHEDULER_Task *listen_task;
400
401 /**
402 * Listen socket. 397 * Listen socket.
403 */ 398 */
404 struct GNUNET_NETWORK_Handle *listen_sock; 399 struct GNUNET_NETWORK_Handle *listen_sock;
@@ -638,11 +633,6 @@ struct ProtoQueue
638 struct ProtoQueue *prev; 633 struct ProtoQueue *prev;
639 634
640 /** 635 /**
641 * ID of listen task
642 */
643 struct GNUNET_SCHEDULER_Task *listen_task;
644
645 /**
646 * Listen socket. 636 * Listen socket.
647 */ 637 */
648 struct GNUNET_NETWORK_Handle *listen_sock; 638 struct GNUNET_NETWORK_Handle *listen_sock;
@@ -761,6 +751,11 @@ static struct GNUNET_TRANSPORT_CommunicatorHandle *ch;
761static struct GNUNET_CONTAINER_MultiPeerMap *queue_map; 751static struct GNUNET_CONTAINER_MultiPeerMap *queue_map;
762 752
763/** 753/**
754 * ListenTasks (map from socket to `struct ListenTask`)
755 */
756static struct GNUNET_CONTAINER_MultiHashMap *lt_map;
757
758/**
764 * Our public key. 759 * Our public key.
765 */ 760 */
766static struct GNUNET_PeerIdentity my_identity; 761static struct GNUNET_PeerIdentity my_identity;
@@ -816,6 +811,16 @@ struct Addresses *addrs_head;
816struct Addresses *addrs_tail; 811struct Addresses *addrs_tail;
817 812
818/** 813/**
814 * Head of DLL with ListenTasks.
815 */
816struct ListenTask *lts_head;
817
818/**
819 * Head of DLL with ListenTask.
820 */
821struct ListenTask *lts_tail;
822
823/**
819 * Number of addresses in the DLL for register at NAT service. 824 * Number of addresses in the DLL for register at NAT service.
820 */ 825 */
821int addrs_lens; 826int addrs_lens;
@@ -850,7 +855,6 @@ unsigned int bind_port;
850static void 855static void
851listen_cb (void *cls); 856listen_cb (void *cls);
852 857
853
854/** 858/**
855 * Functions with this signature are called whenever we need 859 * Functions with this signature are called whenever we need
856 * to close a queue due to a disconnect or failure to 860 * to close a queue due to a disconnect or failure to
@@ -861,10 +865,14 @@ listen_cb (void *cls);
861static void 865static void
862queue_destroy (struct Queue *queue) 866queue_destroy (struct Queue *queue)
863{ 867{
864 struct ListenTask *lt; 868 struct ListenTask *lt = NULL;
865 lt = GNUNET_new (struct ListenTask); 869 struct GNUNET_HashCode h_sock;
866 lt->listen_sock = queue->listen_sock; 870
867 lt->listen_task = queue->listen_task; 871 GNUNET_CRYPTO_hash (queue->listen_sock,
872 sizeof(queue->listen_sock),
873 &h_sock);
874
875 lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
868 876
869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870 "Disconnecting queue for peer `%s'\n", 878 "Disconnecting queue for peer `%s'\n",
@@ -934,7 +942,7 @@ queue_destroy (struct Queue *queue)
934 else 942 else
935 GNUNET_free (queue); 943 GNUNET_free (queue);
936 944
937 if ((NULL != lt->listen_sock) && (NULL == lt->listen_task)) 945 if ((! shutdown_running) && (NULL == lt->listen_task))
938 { 946 {
939 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 947 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
940 "add read net listen\n"); 948 "add read net listen\n");
@@ -1982,7 +1990,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
1982 // colon = strrchr (cp, ':'); 1990 // colon = strrchr (cp, ':');
1983 port = extract_port (bindto); 1991 port = extract_port (bindto);
1984 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); 1992 in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port);
1985 }else{ 1993 }
1994 else{
1986 GNUNET_assert (0); 1995 GNUNET_assert (0);
1987 } 1996 }
1988 1997
@@ -2530,11 +2539,6 @@ decrypt_and_check_tc (struct Queue *queue,
2530static void 2539static void
2531free_proto_queue (struct ProtoQueue *pq) 2540free_proto_queue (struct ProtoQueue *pq)
2532{ 2541{
2533 if (NULL != pq->listen_task)
2534 {
2535 GNUNET_SCHEDULER_cancel (pq->listen_task);
2536 pq->listen_task = NULL;
2537 }
2538 if (NULL != pq->listen_sock) 2542 if (NULL != pq->listen_sock)
2539 { 2543 {
2540 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock)); 2544 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock));
@@ -2653,7 +2657,6 @@ proto_read_kx (void *cls)
2653 queue->address = pq->address; /* steals reference */ 2657 queue->address = pq->address; /* steals reference */
2654 queue->address_len = pq->address_len; 2658 queue->address_len = pq->address_len;
2655 queue->target = tc.sender; 2659 queue->target = tc.sender;
2656 queue->listen_task = pq->listen_task;
2657 queue->listen_sock = pq->listen_sock; 2660 queue->listen_sock = pq->listen_sock;
2658 queue->sock = pq->sock; 2661 queue->sock = pq->sock;
2659 2662
@@ -2696,6 +2699,9 @@ listen_cb (void *cls)
2696 struct ProtoQueue *pq; 2699 struct ProtoQueue *pq;
2697 struct ListenTask *lt; 2700 struct ListenTask *lt;
2698 2701
2702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2703 "listen_cb\n");
2704
2699 lt = cls; 2705 lt = cls;
2700 2706
2701 lt->listen_task = NULL; 2707 lt->listen_task = NULL;
@@ -2909,6 +2915,36 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2909} 2915}
2910 2916
2911/** 2917/**
2918 * Iterator over all ListenTasks to clean up.
2919 *
2920 * @param cls NULL
2921 * @param key unused
2922 * @param value the ListenTask to cancel.
2923 * @return #GNUNET_OK to continue to iterate
2924 */
2925static int
2926get_lt_delete_it (void *cls,
2927 const struct GNUNET_HashCode *key,
2928 void *value)
2929{
2930 struct ListenTask *lt = value;
2931
2932 (void) cls;
2933 (void) key;
2934 if (NULL != lt->listen_task)
2935 {
2936 GNUNET_SCHEDULER_cancel (lt->listen_task);
2937 lt->listen_task = NULL;
2938 }
2939 if (NULL != lt->listen_sock)
2940 {
2941 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (lt->listen_sock));
2942 lt->listen_sock = NULL;
2943 }
2944 return GNUNET_OK;
2945}
2946
2947/**
2912 * Iterator over all message queues to clean up. 2948 * Iterator over all message queues to clean up.
2913 * 2949 *
2914 * @param cls NULL 2950 * @param cls NULL
@@ -2925,16 +2961,10 @@ get_queue_delete_it (void *cls,
2925 2961
2926 (void) cls; 2962 (void) cls;
2927 (void) target; 2963 (void) target;
2928 if (NULL != queue->listen_task)
2929 {
2930 GNUNET_SCHEDULER_cancel (queue->listen_task);
2931 queue->listen_task = NULL;
2932 }
2933 queue_destroy (queue); 2964 queue_destroy (queue);
2934 return GNUNET_OK; 2965 return GNUNET_OK;
2935} 2966}
2936 2967
2937
2938/** 2968/**
2939 * Shutdown the UNIX communicator. 2969 * Shutdown the UNIX communicator.
2940 * 2970 *
@@ -2943,7 +2973,6 @@ get_queue_delete_it (void *cls,
2943static void 2973static void
2944do_shutdown (void *cls) 2974do_shutdown (void *cls)
2945{ 2975{
2946
2947 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2948 "Shutdown %s!\n", 2977 "Shutdown %s!\n",
2949 shutdown_running ? "running" : "not running"); 2978 shutdown_running ? "running" : "not running");
@@ -2960,6 +2989,7 @@ do_shutdown (void *cls)
2960 GNUNET_NAT_unregister (nat); 2989 GNUNET_NAT_unregister (nat);
2961 nat = NULL; 2990 nat = NULL;
2962 } 2991 }
2992 GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL);
2963 GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); 2993 GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL);
2964 GNUNET_CONTAINER_multipeermap_destroy (queue_map); 2994 GNUNET_CONTAINER_multipeermap_destroy (queue_map);
2965 GNUNET_TRANSPORT_communicator_address_remove_all (ch); 2995 GNUNET_TRANSPORT_communicator_address_remove_all (ch);
@@ -2993,6 +3023,8 @@ do_shutdown (void *cls)
2993 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 3023 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
2994 resolve_request_handle = NULL; 3024 resolve_request_handle = NULL;
2995 } 3025 }
3026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3027 "Shutdown done!\n");
2996} 3028}
2997 3029
2998 3030
@@ -3043,10 +3075,10 @@ nat_address_cb (void *cls,
3043 char *my_addr; 3075 char *my_addr;
3044 struct GNUNET_TRANSPORT_AddressIdentifier *ai; 3076 struct GNUNET_TRANSPORT_AddressIdentifier *ai;
3045 3077
3046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3047 "nat address cb %s %s\n", 3079 "nat address cb %s %s\n",
3048 add_remove ? "add" : "remove", 3080 add_remove ? "add" : "remove",
3049 GNUNET_a2s (addr, addrlen)); 3081 GNUNET_a2s (addr, addrlen));
3050 3082
3051 if (GNUNET_YES == add_remove) 3083 if (GNUNET_YES == add_remove)
3052 { 3084 {
@@ -3098,7 +3130,7 @@ add_addr (struct sockaddr *in, socklen_t in_len)
3098 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3099 "add address %s\n", 3131 "add address %s\n",
3100 GNUNET_a2s (saddrs->addr, saddrs->addr_len)); 3132 GNUNET_a2s (saddrs->addr, saddrs->addr_len));
3101 3133
3102 addrs_lens++; 3134 addrs_lens++;
3103} 3135}
3104 3136
@@ -3117,6 +3149,7 @@ init_socket (struct sockaddr *addr,
3117 socklen_t sto_len; 3149 socklen_t sto_len;
3118 struct GNUNET_NETWORK_Handle *listen_sock; 3150 struct GNUNET_NETWORK_Handle *listen_sock;
3119 struct ListenTask *lt; 3151 struct ListenTask *lt;
3152 struct GNUNET_HashCode h_sock;
3120 3153
3121 if (NULL == addr) 3154 if (NULL == addr)
3122 { 3155 {
@@ -3168,13 +3201,12 @@ init_socket (struct sockaddr *addr,
3168 sto_len = in_len; 3201 sto_len = in_len;
3169 } 3202 }
3170 3203
3171 //addr = (struct sockaddr *) &in_sto; 3204 // addr = (struct sockaddr *) &in_sto;
3172 in_len = sto_len; 3205 in_len = sto_len;
3173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3174 "Bound to `%s'\n", 3207 "Bound to `%s'\n",
3175 GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); 3208 GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len));
3176 stats = GNUNET_STATISTICS_create ("C-TCP", cfg); 3209 stats = GNUNET_STATISTICS_create ("C-TCP", cfg);
3177 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
3178 3210
3179 if (NULL == is) 3211 if (NULL == is)
3180 is = GNUNET_NT_scanner_init (); 3212 is = GNUNET_NT_scanner_init ();
@@ -3203,6 +3235,27 @@ init_socket (struct sockaddr *addr,
3203 &listen_cb, 3235 &listen_cb,
3204 lt); 3236 lt);
3205 3237
3238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3239 "creating hash\n");
3240 GNUNET_CRYPTO_hash (lt->listen_sock,
3241 sizeof(lt->listen_sock),
3242 &h_sock);
3243
3244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3245 "creating map\n");
3246 if (NULL == lt_map)
3247 lt_map = GNUNET_CONTAINER_multihashmap_create (2, GNUNET_NO);
3248
3249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3250 "creating map entry\n");
3251 GNUNET_CONTAINER_multihashmap_put (lt_map,
3252 &h_sock,
3253 lt,
3254 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
3255
3256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3257 "map entry created\n");
3258
3206 if (NULL == queue_map) 3259 if (NULL == queue_map)
3207 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 3260 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
3208 3261
@@ -3335,12 +3388,14 @@ init_socket_resolv (void *cls,
3335 { 3388 {
3336 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3389 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
3337 "Address is NULL. This might be an error or the resolver finished resolving.\n"); 3390 "Address is NULL. This might be an error or the resolver finished resolving.\n");
3338 if (NULL == addrs_head){ 3391 if (NULL == addrs_head)
3392 {
3339 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3393 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3340 "Resolver finished resolving, but we do not listen to an address!.\n"); 3394 "Resolver finished resolving, but we do not listen to an address!.\n");
3341 return; 3395 return;
3342 } 3396 }
3343 nat_register (); 3397 nat_register ();
3398
3344 } 3399 }
3345} 3400}
3346 3401
@@ -3405,6 +3460,8 @@ run (void *cls,
3405 return; 3460 return;
3406 } 3461 }
3407 3462
3463 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
3464
3408 if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy)) 3465 if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy))
3409 { 3466 {
3410 po = tcp_address_to_sockaddr_port_only (bindto, &bind_port); 3467 po = tcp_address_to_sockaddr_port_only (bindto, &bind_port);
@@ -3444,6 +3501,7 @@ run (void *cls,
3444 init_socket (in, in_len); 3501 init_socket (in, in_len);
3445 nat_register (); 3502 nat_register ();
3446 GNUNET_free (bindto); 3503 GNUNET_free (bindto);
3504
3447 return; 3505 return;
3448 } 3506 }
3449 3507
@@ -3454,6 +3512,7 @@ run (void *cls,
3454 init_socket (in, in_len); 3512 init_socket (in, in_len);
3455 nat_register (); 3513 nat_register ();
3456 GNUNET_free (bindto); 3514 GNUNET_free (bindto);
3515
3457 return; 3516 return;
3458 } 3517 }
3459 3518
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index e2d2eb73c..aa02bda93 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -124,6 +124,25 @@ communicator_available_cb (void *cls,
124 address_prefix); 124 address_prefix);
125} 125}
126 126
127static void
128open_queue (void *cls)
129{
130 char *address = cls;
131
132 if (NULL != tc_hs[PEER_A]->c_mq)
133 {
134 queue_est = GNUNET_YES;
135 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A],
136 &peer_id[PEER_B],
137 address);
138 }
139 else
140 {
141 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
142 &open_queue,
143 address);
144 }
145}
127 146
128static void 147static void
129add_address_cb (void *cls, 148add_address_cb (void *cls,
@@ -144,10 +163,7 @@ add_address_cb (void *cls,
144 if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && 163 if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) &&
145 (GNUNET_NO == queue_est)) 164 (GNUNET_NO == queue_est))
146 { 165 {
147 queue_est = GNUNET_YES; 166 open_queue (address);
148 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A],
149 &peer_id[PEER_B],
150 address);
151 } 167 }
152} 168}
153 169
diff --git a/src/transport/test_communicator_unix_basic_peer1.conf b/src/transport/test_communicator_unix_basic_peer1.conf
index 71283e381..8e9700108 100644
--- a/src/transport/test_communicator_unix_basic_peer1.conf
+++ b/src/transport/test_communicator_unix_basic_peer1.conf
@@ -28,6 +28,8 @@ PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock 28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29 29
30[communicator-unix] 30[communicator-unix]
31#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
32#PREFIX = valgrind --leak-check=full --track-origins=yes
31UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock 33UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock
32 34
33[communicator-tcp] 35[communicator-tcp]
diff --git a/src/transport/test_communicator_unix_basic_peer2.conf b/src/transport/test_communicator_unix_basic_peer2.conf
index ac95845b2..c12cc9111 100644
--- a/src/transport/test_communicator_unix_basic_peer2.conf
+++ b/src/transport/test_communicator_unix_basic_peer2.conf
@@ -28,6 +28,8 @@ PORT = 62090
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock 28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
29 29
30[communicator-unix] 30[communicator-unix]
31#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
32#PREFIX = valgrind --leak-check=full --track-origins=yes
31UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock 33UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock
32 34
33[communicator-tcp] 35[communicator-tcp]
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index e194b0159..98cfd5e29 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -59,145 +59,6 @@ struct MyClient
59}; 59};
60 60
61/** 61/**
62 * @brief Handle to a transport communicator
63 */
64struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
65{
66 /**
67 * Clients
68 */
69 struct MyClient *client_head;
70 struct MyClient *client_tail;
71
72 /**
73 * @brief Handle to the client
74 */
75 struct GNUNET_MQ_Handle *c_mq;
76
77 /**
78 * @brief Handle to the configuration
79 */
80 struct GNUNET_CONFIGURATION_Handle *cfg;
81
82 /**
83 * @brief File name of configuration file
84 */
85 char *cfg_filename;
86
87 struct GNUNET_PeerIdentity peer_id;
88
89 /**
90 * @brief Handle to the transport service
91 */
92 struct GNUNET_SERVICE_Handle *tsh;
93
94 /**
95 * @brief Task that will be run on shutdown to stop and clean transport
96 * service
97 */
98 struct GNUNET_SCHEDULER_Task *ts_shutdown_task;
99
100
101 /**
102 * @brief Process of the communicator
103 */
104 struct GNUNET_OS_Process *c_proc;
105
106 /**
107 * NAT process
108 */
109 struct GNUNET_OS_Process *nat_proc;
110
111 /**
112 * resolver service process
113 */
114 struct GNUNET_OS_Process *resolver_proc;
115
116 /**
117 * peerstore service process
118 */
119 struct GNUNET_OS_Process *ps_proc;
120
121 /**
122 * @brief Task that will be run on shutdown to stop and clean communicator
123 */
124 struct GNUNET_SCHEDULER_Task *c_shutdown_task;
125
126 /**
127 * @brief Characteristics of the communicator
128 */
129 enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics;
130
131 /**
132 * @brief Specifies supported addresses
133 */
134 char *c_addr_prefix;
135
136 /**
137 * @brief Specifies supported addresses
138 */
139 char *c_address;
140
141 /**
142 * @brief Head of the DLL of queues associated with this communicator
143 */
144 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head;
145
146 /**
147 * @brief Tail of the DLL of queues associated with this communicator
148 */
149 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail;
150
151 /* Callbacks + Closures */
152 /**
153 * @brief Callback called when a new communicator connects
154 */
155 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
156 communicator_available_cb;
157
158 /**
159 * @brief Callback called when a new communicator connects
160 */
161 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb;
162
163 /**
164 * @brief Callback called when a new communicator connects
165 */
166 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb;
167
168 /**
169 * @brief Callback called when a new communicator connects
170 */
171 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb;
172
173 /**
174 * @brief Callback called when a new communicator connects
175 */
176 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
177
178 /**
179 * @brief Backchannel callback
180 */
181 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb;
182
183 /**
184 * Our service handle
185 */
186 struct GNUNET_SERVICE_Handle *sh;
187
188 /**
189 * @brief Closure to the callback
190 */
191 void *cb_cls;
192
193 /**
194 * Backchannel supported
195 */
196 int bc_enabled;
197};
198
199
200/**
201 * @brief Queue of a communicator and some context 62 * @brief Queue of a communicator and some context
202 */ 63 */
203struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue 64struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
@@ -707,6 +568,9 @@ shutdown_service (void *cls)
707{ 568{
708 struct GNUNET_SERVICE_Handle *h = cls; 569 struct GNUNET_SERVICE_Handle *h = cls;
709 570
571 LOG (GNUNET_ERROR_TYPE_DEBUG,
572 "Shutting down service!\n");
573
710 GNUNET_SERVICE_stop (h); 574 GNUNET_SERVICE_stop (h);
711} 575}
712 576
@@ -1202,6 +1066,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
1202 memcpy (&msg[1], address, alen); 1066 memcpy (&msg[1], address, alen);
1203 if (NULL != tc_h->c_mq) 1067 if (NULL != tc_h->c_mq)
1204 { 1068 {
1069 LOG (GNUNET_ERROR_TYPE_DEBUG,
1070 "Sending queue create immediately\n");
1205 GNUNET_MQ_send (tc_h->c_mq, env); 1071 GNUNET_MQ_send (tc_h->c_mq, env);
1206 } 1072 }
1207 else 1073 else
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index b77125e82..04f75fc88 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -29,13 +29,6 @@
29#include "gnunet_ats_transport_service.h" 29#include "gnunet_ats_transport_service.h"
30#include "transport.h" 30#include "transport.h"
31 31
32
33/**
34 * @brief Handle to a transport communicator
35 */
36struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle;
37
38
39/** 32/**
40 * @brief Queue of a communicator and some context 33 * @brief Queue of a communicator and some context
41 */ 34 */
@@ -151,6 +144,143 @@ typedef void
151 const char*payload, 144 const char*payload,
152 size_t payload_len); 145 size_t payload_len);
153 146
147/**
148 * @brief Handle to a transport communicator
149 */
150struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
151{
152 /**
153 * Clients
154 */
155 struct MyClient *client_head;
156 struct MyClient *client_tail;
157
158 /**
159 * @brief Handle to the client
160 */
161 struct GNUNET_MQ_Handle *c_mq;
162
163 /**
164 * @brief Handle to the configuration
165 */
166 struct GNUNET_CONFIGURATION_Handle *cfg;
167
168 /**
169 * @brief File name of configuration file
170 */
171 char *cfg_filename;
172
173 struct GNUNET_PeerIdentity peer_id;
174
175 /**
176 * @brief Handle to the transport service
177 */
178 struct GNUNET_SERVICE_Handle *tsh;
179
180 /**
181 * @brief Task that will be run on shutdown to stop and clean transport
182 * service
183 */
184 struct GNUNET_SCHEDULER_Task *ts_shutdown_task;
185
186
187 /**
188 * @brief Process of the communicator
189 */
190 struct GNUNET_OS_Process *c_proc;
191
192 /**
193 * NAT process
194 */
195 struct GNUNET_OS_Process *nat_proc;
196
197 /**
198 * resolver service process
199 */
200 struct GNUNET_OS_Process *resolver_proc;
201
202 /**
203 * peerstore service process
204 */
205 struct GNUNET_OS_Process *ps_proc;
206
207 /**
208 * @brief Task that will be run on shutdown to stop and clean communicator
209 */
210 struct GNUNET_SCHEDULER_Task *c_shutdown_task;
211
212 /**
213 * @brief Characteristics of the communicator
214 */
215 enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics;
216
217 /**
218 * @brief Specifies supported addresses
219 */
220 char *c_addr_prefix;
221
222 /**
223 * @brief Specifies supported addresses
224 */
225 char *c_address;
226
227 /**
228 * @brief Head of the DLL of queues associated with this communicator
229 */
230 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head;
231
232 /**
233 * @brief Tail of the DLL of queues associated with this communicator
234 */
235 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail;
236
237 /* Callbacks + Closures */
238 /**
239 * @brief Callback called when a new communicator connects
240 */
241 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
242 communicator_available_cb;
243
244 /**
245 * @brief Callback called when a new communicator connects
246 */
247 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb;
248
249 /**
250 * @brief Callback called when a new communicator connects
251 */
252 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb;
253
254 /**
255 * @brief Callback called when a new communicator connects
256 */
257 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb;
258
259 /**
260 * @brief Callback called when a new communicator connects
261 */
262 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
263
264 /**
265 * @brief Backchannel callback
266 */
267 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb;
268
269 /**
270 * Our service handle
271 */
272 struct GNUNET_SERVICE_Handle *sh;
273
274 /**
275 * @brief Closure to the callback
276 */
277 void *cb_cls;
278
279 /**
280 * Backchannel supported
281 */
282 int bc_enabled;
283};
154 284
155/** 285/**
156 * @brief Start communicator part of transport service and communicator 286 * @brief Start communicator part of transport service and communicator
diff --git a/src/util/mq.c b/src/util/mq.c
index 302b310de..29ead02a4 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -273,7 +273,7 @@ GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers,
273 break; 273 break;
274 } 274 }
275 } 275 }
276done: 276 done:
277 if (GNUNET_NO == handled) 277 if (GNUNET_NO == handled)
278 { 278 {
279 LOG (GNUNET_ERROR_TYPE_INFO, 279 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -355,6 +355,10 @@ void
355GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, 355GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
356 struct GNUNET_MQ_Envelope *ev) 356 struct GNUNET_MQ_Envelope *ev)
357{ 357{
358 if (NULL == mq)
359 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
360 "mq is NUll when sending message of type %u\n",
361 (unsigned int) ntohs (ev->mh->type));
358 GNUNET_assert (NULL != mq); 362 GNUNET_assert (NULL != mq);
359 GNUNET_assert (NULL == ev->parent_queue); 363 GNUNET_assert (NULL == ev->parent_queue);
360 364