diff options
Diffstat (limited to 'src/vpn/gnunet-daemon-vpn-dns.c')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn-dns.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/vpn/gnunet-daemon-vpn-dns.c b/src/vpn/gnunet-daemon-vpn-dns.c index 9ee81011e..7f762238c 100644 --- a/src/vpn/gnunet-daemon-vpn-dns.c +++ b/src/vpn/gnunet-daemon-vpn-dns.c | |||
@@ -46,6 +46,8 @@ unsigned char restart_hijack; | |||
46 | struct answer_packet_list *answer_proc_head; | 46 | struct answer_packet_list *answer_proc_head; |
47 | struct answer_packet_list *answer_proc_tail; | 47 | struct answer_packet_list *answer_proc_tail; |
48 | 48 | ||
49 | struct GNUNET_CLIENT_TransmitHandle *dns_transmit_handle; | ||
50 | |||
49 | /** | 51 | /** |
50 | * Callback called by notify_transmit_ready; sends dns-queries or rehijack-messages | 52 | * Callback called by notify_transmit_ready; sends dns-queries or rehijack-messages |
51 | * to the service-dns | 53 | * to the service-dns |
@@ -55,6 +57,7 @@ size_t | |||
55 | send_query (void *cls __attribute__ ((unused)), size_t size, void *buf) | 57 | send_query (void *cls __attribute__ ((unused)), size_t size, void *buf) |
56 | { | 58 | { |
57 | size_t len; | 59 | size_t len; |
60 | dns_transmit_handle = NULL; | ||
58 | 61 | ||
59 | /* | 62 | /* |
60 | * Send the rehijack-message | 63 | * Send the rehijack-message |
@@ -97,14 +100,14 @@ send_query (void *cls __attribute__ ((unused)), size_t size, void *buf) | |||
97 | */ | 100 | */ |
98 | if (head != NULL) | 101 | if (head != NULL) |
99 | { | 102 | { |
100 | GNUNET_CLIENT_notify_transmit_ready (dns_connection, | 103 | dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection, |
101 | ntohs (head->pkt.hdr.size), | 104 | ntohs (head->pkt.hdr.size), |
102 | GNUNET_TIME_UNIT_FOREVER_REL, | 105 | GNUNET_TIME_UNIT_FOREVER_REL, |
103 | GNUNET_YES, &send_query, NULL); | 106 | GNUNET_YES, &send_query, NULL); |
104 | } | 107 | } |
105 | else if (restart_hijack == 1) | 108 | else if (restart_hijack == 1) |
106 | { | 109 | { |
107 | GNUNET_CLIENT_notify_transmit_ready (dns_connection, | 110 | dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection, |
108 | sizeof (struct GNUNET_MessageHeader), | 111 | sizeof (struct GNUNET_MessageHeader), |
109 | GNUNET_TIME_UNIT_FOREVER_REL, | 112 | GNUNET_TIME_UNIT_FOREVER_REL, |
110 | GNUNET_YES, &send_query, NULL); | 113 | GNUNET_YES, &send_query, NULL); |
@@ -140,14 +143,14 @@ connect_to_service_dns (void *cls | |||
140 | return; | 143 | return; |
141 | 144 | ||
142 | /* If a packet is already in the list, schedule to send it */ | 145 | /* If a packet is already in the list, schedule to send it */ |
143 | if (head != NULL) | 146 | if (dns_transmit_handle == NULL && head != NULL) |
144 | GNUNET_CLIENT_notify_transmit_ready (dns_connection, | 147 | dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection, |
145 | ntohs (head->pkt.hdr.size), | 148 | ntohs (head->pkt.hdr.size), |
146 | GNUNET_TIME_UNIT_FOREVER_REL, | 149 | GNUNET_TIME_UNIT_FOREVER_REL, |
147 | GNUNET_YES, &send_query, NULL); | 150 | GNUNET_YES, &send_query, NULL); |
148 | else if (restart_hijack == 1) | 151 | else if (dns_transmit_handle == NULL && restart_hijack == 1) |
149 | { | 152 | { |
150 | GNUNET_CLIENT_notify_transmit_ready (dns_connection, | 153 | dns_transmit_handle = GNUNET_CLIENT_notify_transmit_ready (dns_connection, |
151 | sizeof (struct GNUNET_MessageHeader), | 154 | sizeof (struct GNUNET_MessageHeader), |
152 | GNUNET_TIME_UNIT_FOREVER_REL, | 155 | GNUNET_TIME_UNIT_FOREVER_REL, |
153 | GNUNET_YES, &send_query, NULL); | 156 | GNUNET_YES, &send_query, NULL); |
@@ -166,6 +169,9 @@ dns_answer_handler (void *cls | |||
166 | /* the service disconnected, reconnect after short wait */ | 169 | /* the service disconnected, reconnect after short wait */ |
167 | if (msg == NULL) | 170 | if (msg == NULL) |
168 | { | 171 | { |
172 | if (dns_transmit_handle != NULL) | ||
173 | GNUNET_CLIENT_notify_transmit_ready_cancel(dns_transmit_handle); | ||
174 | dns_transmit_handle = NULL; | ||
169 | GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO); | 175 | GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO); |
170 | dns_connection = NULL; | 176 | dns_connection = NULL; |
171 | conn_task = | 177 | conn_task = |