]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
crash less often at exit
authorAlan T. DeKok <aland@freeradius.org>
Thu, 6 Feb 2020 14:14:36 +0000 (09:14 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 6 Feb 2020 14:14:36 +0000 (09:14 -0500)
src/modules/rlm_radius/rlm_radius_udp.c

index eb2bf0c804af094b4b5b06ec6d23b9abf8af5837..aecf6fcb94feac8acdbf3b2d01e892eed79cf3c2 100644 (file)
@@ -956,6 +956,8 @@ static void check_for_zombie(fr_event_list_t *el, udp_handle_t *h, fr_time_t now
 
        if (!now) now = fr_time();
 
+       if (!h->last_reply && !h->last_sent) return;
+
        /*
         *      We have recent replies, do nothing.
         */
@@ -1419,6 +1421,7 @@ drain:
        if (data_len < 0) {
                if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) return NULL;
 
+               DEBUG("Failed reading from socket: %s", fr_syserror(errno));
                fr_trunk_connection_signal_reconnect(c->tconn, FR_CONNECTION_FAILED);
                return NULL;
        }
@@ -1694,23 +1697,26 @@ static int udp_request_free(udp_request_t *u)
 {
        udp_handle_t *h;
 
+       if (u->ev) (void) fr_event_timer_delete(&u->ev);
+
        /*
         *      We don't have a connection, so we can't update any of
         *      the connection timers or states.
         */
        if (!u->c) return 0;
 
-       if (u->ev) (void) fr_event_timer_delete(&u->ev);
-
-       h = talloc_get_type_abort(u->c->conn->h, udp_handle_t);
-
        /*
-        *      The module is doing async proxying, we don't need to
-        *      do more.
+        *      No resources allocated to the packet.
         */
-       if (!u->synchronous) return 0;
+       if (!u->rr) return 0;
 
-       if (u->rr) (void) rr_track_delete(h->id, u->rr);
+       /*
+        *      @todo - this crashes on exit if there are pending
+        *      requests, because "conn" is freed before this function
+        *      is called.
+        */
+       h = talloc_get_type_abort(u->c->conn->h, udp_handle_t);
+       (void) rr_track_delete(h->id, u->rr);
 
        return 0;
 }