chiark / gitweb /
src/types.c: Start on IPv6 support in adns_r_addr queries.
[adns.git] / src / internal.h
index 5e3495610f24140c130c6a5ff45a48c8a242031c..a95bf4d6a15b79f5ff9955ef015f0a7e863ad835 100644 (file)
@@ -151,6 +151,9 @@ typedef struct {
       adns_rrtype rev_rrtype;
       struct af_addr addr;
     } ptr;
       adns_rrtype rev_rrtype;
       struct af_addr addr;
     } ptr;
+    struct {
+      unsigned want, have;
+    } addr;
   } tinfo; /* type-specific state for the query itself: zero-init if you
            * don't know better. */
 
   } tinfo; /* type-specific state for the query itself: zero-init if you
            * don't know better. */
 
@@ -319,6 +322,10 @@ struct adns__query {
    * Queries in state tcpw/tcpw have been sent (or are in the to-send buffer)
    * iff the tcp connection is in state server_ok.
    *
    * Queries in state tcpw/tcpw have been sent (or are in the to-send buffer)
    * iff the tcp connection is in state server_ok.
    *
+   * Internal queries (from adns__submit_internal) end up on intdone
+   * instead of output, and the callbacks are made on the way out of
+   * adns, to avoid reentrancy hazards.
+   *
    *                         +------------------------+
    *             START -----> |      tosend/NONE       |
    *                         +------------------------+
    *                         +------------------------+
    *             START -----> |      tosend/NONE       |
    *                         +------------------------+
@@ -364,7 +371,7 @@ struct adns__state {
   adns_logcallbackfn *logfn;
   void *logfndata;
   int configerrno;
   adns_logcallbackfn *logfn;
   void *logfndata;
   int configerrno;
-  struct query_queue udpw, tcpw, childw, output;
+  struct query_queue udpw, tcpw, childw, output, intdone;
   adns_query forallnext;
   int nextid, tcpsocket;
   struct udpsocket { int af; int fd; } udpsocket[MAXUDP];
   adns_query forallnext;
   int nextid, tcpsocket;
   struct udpsocket { int af; int fd; } udpsocket[MAXUDP];
@@ -601,6 +608,7 @@ void adns__query_send(adns_query qu, struct timeval now);
 /* From query.c: */
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
 /* From query.c: */
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
+                                 adns_query parent,
                                  const typeinfo *typei, adns_rrtype type,
                                  vbuf *qumsg_vb, int id,
                                  adns_queryflags flags, struct timeval now,
                                  const typeinfo *typei, adns_rrtype type,
                                  vbuf *qumsg_vb, int id,
                                  adns_queryflags flags, struct timeval now,
@@ -703,10 +711,19 @@ void adns__reset_preserved(adns_query qu);
  * in a datagram and discover that we need to retry the query.
  */
 
  * in a datagram and discover that we need to retry the query.
  */
 
+void adns__cancel(adns_query qu);
 void adns__query_done(adns_query qu);
 void adns__query_fail(adns_query qu, adns_status stat);
 void adns__cancel_children(adns_query qu);
 
 void adns__query_done(adns_query qu);
 void adns__query_fail(adns_query qu, adns_status stat);
 void adns__cancel_children(adns_query qu);
 
+void adns__returning(adns_state ads, adns_query qu);
+/* Must be called before returning from adns any time that we have
+ * progressed (including made, finished or destroyed) queries.
+ *
+ * Might reenter adns via internal query callbacks, so
+ * external-faciing functions which call adns__returning should
+ * normally be avoided in internal code. */
+
 /* From reply.c: */
 
 void adns__procdgram(adns_state ads, const byte *dgram, int len,
 /* From reply.c: */
 
 void adns__procdgram(adns_state ads, const byte *dgram, int len,
@@ -871,6 +888,7 @@ void adns__autosys(adns_state ads, struct timeval now);
 
 void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
                             struct timeval *tv_buf);
 
 void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
                             struct timeval *tv_buf);
+/* Call with care - might reentrantly cause queries to be completed! */
 
 int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS]);
 void adns__fdevents(adns_state ads,
 
 int adns__pollfds(adns_state ads, struct pollfd pollfds_buf[MAX_POLLFDS]);
 void adns__fdevents(adns_state ads,