From 6ff9f189497d20e6336dbb962f2a41c991ba2a9d Mon Sep 17 00:00:00 2001 From: Dante Date: Tue, 15 Sep 2009 23:08:29 +0200 Subject: [PATCH] Track the number of outstanding packets on a TCP connection. 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 --- src/include/radiusd.h | 3 +++ src/main/event.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/include/radiusd.h b/src/include/radiusd.h index 7a394c8..f26ffef 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -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; diff --git a/src/main/event.c b/src/main/event.c index e39811a..92c1fb7 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -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. -- 2.1.4