Track the number of outstanding packets on a TCP connection.
authorDante <dante@dante.org.uk>
Tue, 15 Sep 2009 21:08:29 +0000 (23:08 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 15 Sep 2009 21:08:29 +0000 (23:08 +0200)
This allows us to free the connection when all packets are
accounted for, and the connection is to be marked "closed"

Signed-off-by: Alan T. DeKok <aland@freeradius.org>
src/include/radiusd.h
src/main/event.c

index 7a394c8..f26ffef 100644 (file)
@@ -318,6 +318,9 @@ struct rad_listen_t {
        int             fd;
        const char      *server;
        int             status;
+#ifdef WITH_TCP
+       int             count;
+#endif
 
        rad_listen_recv_t recv;
        rad_listen_send_t send;
index e39811a..92c1fb7 100644 (file)
@@ -143,6 +143,19 @@ static void remove_from_request_hash(REQUEST *request)
        request->in_request_hash = FALSE;
 
        request_stats_final(request);
+
+#ifdef WITH_TCP
+       request->listener->count--;
+
+       /*
+        *      The TCP socket was closed, but we've got to
+        *      hang around until done.
+        */
+       if ((request->listener->status == RAD_LISTEN_STATUS_FINISH) &&
+           (request->listener->count == 0)) {
+               listen_free(&request->listener);
+       }
+#endif
 }
 
 
@@ -2887,6 +2900,9 @@ int received_request(rad_listen_t *listener,
        request->in_request_hash = TRUE;
        request->root = root;
        root->refcount++;
+#ifdef WITH_TCP
+       request->listener->count++;
+#endif
 
        /*
         *      The request passes many of our sanity checks.