]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Set "last packet" entry for all sockets
authorAlan T. DeKok <aland@freeradius.org>
Fri, 13 May 2011 11:44:35 +0000 (13:44 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 May 2011 11:44:35 +0000 (13:44 +0200)
This will help us track TCP connections

src/main/listen.c
src/main/process.c

index ff15ebe0857ee8502b3a27e2b2f64cd8e9f2ed2e..1fb1286b366c469a3dc381729452b3b29ae707a0 100644 (file)
@@ -631,6 +631,7 @@ static int dual_tcp_accept(rad_listen_t *listener)
        sock->other_ipaddr = src_ipaddr;
        sock->other_port = src_port;
        sock->client = client;
+       sock->opened = sock->last_packet = time(NULL);
 
        this->fd = newfd;
        this->status = RAD_LISTEN_STATUS_INIT;
index f65afb1fe6a84f223c79ef58340cb92c639a40e2..b5aba402199dd74c579b9d2da37d5e74274e4eb0 100644 (file)
@@ -1186,6 +1186,20 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet,
        int count;
        RADIUS_PACKET **packet_p;
        REQUEST *request = NULL;
+       struct timeval now;
+
+       /*
+        *      Set the last packet received.
+        */
+       gettimeofday(&now, NULL);
+#ifdef WITH_DETAIL
+       if (listener->type != RAD_LISTEN_DETAIL)
+#endif
+       {
+               listen_socket_t *sock = listener->data;
+
+               sock->last_packet = now.tv_sec;
+       }
 
        packet_p = fr_packet_list_find(pl, packet);
        if (packet_p) {
@@ -1248,8 +1262,6 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet,
            (listener->type != RAD_LISTEN_DETAIL)  &&
 #endif
            ((count = fr_packet_list_num_elements(pl)) > mainconfig.max_requests)) {
-               struct timeval now;
-
                static time_t last_complained = 0;
 
                radlog(L_ERR, "Dropping request (%d is too many): from client %s port %d - ID: %d", count,
@@ -1261,7 +1273,6 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet,
                /*
                 *      Complain once every 10 seconds.
                 */
-               gettimeofday(&now, NULL);
                if ((last_complained + 10) < now.tv_sec) {
                        last_complained = now.tv_sec;
                        exec_trigger(NULL, NULL, "server.max_requests");
@@ -1284,7 +1295,7 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet,
        request->listener = listener;
        request->client = client;
        request->packet = packet;
-       gettimeofday(&request->packet->timestamp, NULL);
+       request->packet->timestamp = now;
        request->number = request_num_counter++;
        request->priority = listener->type;
        request->master_state = REQUEST_ACTIVE;
@@ -1737,7 +1748,10 @@ int request_proxy_reply(RADIUS_PACKET *packet)
         *      Status-Server packets don't count as real packets.
         */
        if (request->proxy->code != PW_STATUS_SERVER) {
+               listen_socket_t *sock = request->proxy_listener->data;
+
                request->home_server->last_packet = now.tv_sec;
+               sock->last_packet = now.tv_sec;
        }
 
        /*