fix SIGSEGV if dns was slow to start up
authorPhilipp Tölke <toelke@in.tum.de>
Thu, 24 Feb 2011 14:44:04 +0000 (14:44 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Thu, 24 Feb 2011 14:44:04 +0000 (14:44 +0000)
src/vpn/gnunet-daemon-vpn-dns.c
src/vpn/gnunet-daemon-vpn-helper.c

index 7d0b38d8c37122c9e3675135aec6ab65a50f5f31..07e2d6059e91e3606f0e76bd0e67ef90f979580d 100644 (file)
@@ -117,9 +117,12 @@ connect_to_service_dns (void *cls,
     GNUNET_assert (dns_connection == NULL);
     dns_connection = GNUNET_CLIENT_connect ("dns", cfg);
     /* This would most likely be a misconfiguration */
-    GNUNET_assert(dns_connection != NULL);
+    GNUNET_assert(NULL != dns_connection);
     GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
 
+    /* We might not yet be connected. Yay, mps. */
+    if (NULL == dns_connection) return;
+
     /* If a packet is already in the list, schedule to send it */
     if (head != NULL)
       GNUNET_CLIENT_notify_transmit_ready(dns_connection,
index 1317c9ade4404458bde0d5fe9766abc982401a0c..9df2a8cc004fd568a9a09fa3bf879646db38472f 100644 (file)
@@ -122,7 +122,8 @@ start_helper_and_schedule(void *cls,
      * The routing-table gets flushed if an interface disappears.
      */
     restart_hijack = 1;
-    GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL);
+    if (NULL != dns_connection)
+      GNUNET_CLIENT_notify_transmit_ready(dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL);
 }
 /*}}}*/