chiark / gitweb /
Reentrancy: Avoid reentrant callbacks
[adns.git] / src / internal.h
index 3297f12544b155067b7cde088ac51f37ed0a8cc3..4144ec18e8e30cbf90e8c2b216d5906a443df4a9 100644 (file)
@@ -328,6 +328,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.
    *
+   * 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       |
    *                         +------------------------+
@@ -373,7 +377,7 @@ struct adns__state {
   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];
@@ -720,7 +724,11 @@ 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. */
+ * 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: */