From a55e184722c9606ceb01bcb4579d5160f3d64e73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Thu, 7 Oct 2010 05:41:54 +0000 Subject: [PATCH] Reconnect to the service-dns if the connection is lost (or at the start of gnunet for whatever reason) --- src/vpn/gnunet-daemon-vpn.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index cc408dc62..354e090d8 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -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); -- 2.25.1