Reconnect to the service-dns if the connection is lost (or at the start of
authorPhilipp Tölke <toelke@in.tum.de>
Thu, 7 Oct 2010 05:41:54 +0000 (05:41 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Thu, 7 Oct 2010 05:41:54 +0000 (05:41 +0000)
gnunet for whatever reason)

src/vpn/gnunet-daemon-vpn.c

index cc408dc62686b366562b5016aef1e644baf23184..354e090d85ff58cee60b6382f85c5402bcfe9b6f 100644 (file)
@@ -56,6 +56,8 @@ struct vpn_cls {
 
        pid_t helper_pid;
 
+       const struct GNUNET_CONFIGURATION_Handle *cfg;
+
        struct query_packet_list *head;
        struct query_packet_list *tail;
 
@@ -254,8 +256,16 @@ static void message_token(void *cls, void *client, const struct GNUNET_MessageHe
 
 }
 
+void dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg);
+
+void reconnect_to_service_dns() {
+  mycls.dns_connection = GNUNET_CLIENT_connect (mycls.sched, "dns", mycls.cfg);
+
+  GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
+}
+
 void dns_answer_handler(void* cls, const struct GNUNET_MessageHeader *msg) {
-       if (msg == NULL) return;
+       if (msg == NULL) reconnect_to_service_dns();
 
        if (msg->type != htons(GNUNET_MESSAGE_TYPE_LOCAL_RESPONSE_DNS)) goto out;
 
@@ -290,9 +300,9 @@ run (void *cls,
   mycls.sched = sched;
   mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL);
 
-  mycls.dns_connection = GNUNET_CLIENT_connect (sched, "dns", cfg);
+  mycls.cfg = cfg;
 
-  GNUNET_CLIENT_receive(mycls.dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
+  reconnect_to_service_dns();
 
   GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); 
   start_helper_and_schedule(mycls);