Purge the duplication cache once per received packet.
authorLinus Nordberg <linus@nordberg.se>
Mon, 26 Aug 2013 12:25:51 +0000 (14:25 +0200)
committerLinus Nordberg <linus@nordberg.se>
Mon, 2 Sep 2013 11:46:55 +0000 (13:46 +0200)
radsecproxy.c

index d05f9c9..3e4f360 100644 (file)
@@ -1390,6 +1390,22 @@ struct request *newrequest() {
     return rq;
 }
 
+static void
+purgedupcache(struct client *client) {
+    struct request *r;
+    struct timeval now;
+    int i;
+
+    gettimeofday(&now, NULL);
+    for (i = 0; i < MAX_REQUESTS; i++) {
+       r = client->rqs[i];
+       if (r && now.tv_sec - r->created.tv_sec > r->from->conf->dupinterval) {
+           freerq(r);
+           client->rqs[i] = NULL;
+       }
+    }
+}
+
 int addclientrq(struct request *rq) {
     struct request *r;
     struct timeval now;
@@ -1453,6 +1469,7 @@ int radsrv(struct request *rq) {
        goto exit;
     }
 
+    purgedupcache(from);
     if (!addclientrq(rq))
        goto exit;