bug
authorPhilipp Tölke <toelke@in.tum.de>
Wed, 5 Oct 2011 08:58:50 +0000 (08:58 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Wed, 5 Oct 2011 08:58:50 +0000 (08:58 +0000)
src/vpn/gnunet-daemon-vpn-dns.c
src/vpn/gnunet-daemon-vpn-helper.c

index 9ee81011ee8d0da31978385cc645c74828222962..7f762238cbd4a848ccc60b03e6b02f34d187a078 100644 (file)
@@ -46,6 +46,8 @@ unsigned char restart_hijack;
 struct answer_packet_list *answer_proc_head;
 struct answer_packet_list *answer_proc_tail;
 
+struct GNUNET_CLIENT_TransmitHandle *dns_transmit_handle;
+
 /**
  * Callback called by notify_transmit_ready; sends dns-queries or rehijack-messages
  * to the service-dns
@@ -55,6 +57,7 @@ size_t
 send_query (void *cls __attribute__ ((unused)), size_t size, void *buf)
 {
   size_t len;
+  dns_transmit_handle = NULL;
 
   /*
    * Send the rehijack-message
@@ -97,14 +100,14 @@ send_query (void *cls __attribute__ ((unused)), size_t size, void *buf)
    */
   if (head != NULL)
   {
-    GNUNET_CLIENT_notify_transmit_ready (dns_connection,
+    dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection,
                                          ntohs (head->pkt.hdr.size),
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          GNUNET_YES, &send_query, NULL);
   }
   else if (restart_hijack == 1)
   {
-    GNUNET_CLIENT_notify_transmit_ready (dns_connection,
+    dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection,
                                          sizeof (struct GNUNET_MessageHeader),
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          GNUNET_YES, &send_query, NULL);
@@ -140,14 +143,14 @@ connect_to_service_dns (void *cls
     return;
 
   /* If a packet is already in the list, schedule to send it */
-  if (head != NULL)
-    GNUNET_CLIENT_notify_transmit_ready (dns_connection,
+  if (dns_transmit_handle == NULL && head != NULL)
+    dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection,
                                          ntohs (head->pkt.hdr.size),
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          GNUNET_YES, &send_query, NULL);
-  else if (restart_hijack == 1)
+  else if (dns_transmit_handle == NULL && restart_hijack == 1)
   {
-    GNUNET_CLIENT_notify_transmit_ready (dns_connection,
+    dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection,
                                          sizeof (struct GNUNET_MessageHeader),
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          GNUNET_YES, &send_query, NULL);
@@ -166,6 +169,9 @@ dns_answer_handler (void *cls
   /* the service disconnected, reconnect after short wait */
   if (msg == NULL)
   {
+    if (dns_transmit_handle != NULL)
+      GNUNET_CLIENT_notify_transmit_ready_cancel(dns_transmit_handle);
+    dns_transmit_handle = NULL;
     GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO);
     dns_connection = NULL;
     conn_task =
index eed073e07e19d13bb837afeddfb1b148a1153a3b..d91b00416915dbf735ba66e39b160892cb57fa31 100644 (file)
@@ -45,6 +45,8 @@
 
 struct GNUNET_VPN_HELPER_Handle *helper_handle;
 
+extern struct GNUNET_CLIENT_TransmitHandle* dns_transmit_handle;
+
 /**
  * The tunnels that will be used to send tcp- and udp-packets
  */
@@ -137,8 +139,8 @@ start_helper_and_schedule (void *cls,
    * The routing-table gets flushed if an interface disappears.
    */
   restart_hijack = 1;
-  if (NULL != dns_connection)
-    GNUNET_CLIENT_notify_transmit_ready (dns_connection,
+  if (NULL != dns_connection && dns_transmit_handle == NULL)
+    dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection,
                                          sizeof (struct GNUNET_MessageHeader),
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          GNUNET_YES, &send_query, NULL);
@@ -445,10 +447,10 @@ message_token (void *cls __attribute__ ((unused)), void *client
 
       GNUNET_assert (head != NULL);
 
-      if (dns_connection != NULL)
-        GNUNET_CLIENT_notify_transmit_ready (dns_connection, len,
-                                             GNUNET_TIME_UNIT_FOREVER_REL,
-                                             GNUNET_YES, &send_query, NULL);
+      if (dns_connection != NULL && dns_transmit_handle == NULL)
+        dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection, len,
+                                                                   GNUNET_TIME_UNIT_FOREVER_REL,
+                                                                   GNUNET_YES, &send_query, NULL);
     }
     else
     {