{
rlm_radius_udp_connection_t *c = talloc_get_type_abort(uctx, rlm_radius_udp_connection_t);
fr_dlist_t *entry, *next;
+ bool pending;
/*
* Clear our backlog
/*
* Check if we have to enable or disable writing on the socket.
*/
- entry = FR_DLIST_FIRST(c->queued);
- if (!entry) {
- c->pending = false;
- fd_idle(c);
-
- } else if (!c->pending) {
+ pending = ((entry = FR_DLIST_FIRST(c->queued)) != NULL);
+ if (!pending && c->pending) {
/*
- * This check is here only for mod_push(), which
- * calls us when there are no packets pending on
- * a socket. If the connection is writable, and
- * the write succeeds, and there's nothing more
- * to write, we don't need to call fd_active().
+ * The queue is empty, and we apparently just
+ * emptied it. Set the FD to idle.
*/
- c->pending = true;
- fd_active(c);
+ c->pending = false;
+ fd_idle(c);
}
/*
- * Else c->pending was already set, and we already have fd_active().
+ * This check is here only for mod_push(), which
+ * calls us when there are no packets pending on
+ * a socket. If the connection is writable, and
+ * the write succeeds, and there's nothing more
+ * to write, we don't need to call fd_active().
*/
+ else if (pending && !c->pending) {
+ c->pending = true;
+ fd_active(c);
+ }
}
/** Shutdown/close a file descriptor
fd_active(c);
}
}
+
+ /*
+ * Update the pending flag.
+ */
+ t->pending = ((entry = FR_DLIST_FIRST(t->queued)) != NULL);
}
ERROR("There are still queued requests");
return -1;
}
+ rad_assert(t->pending == false);
/*
* Free all of the sockets.