]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
grab another coa tunnel listener if this one is full
authorAlan T. DeKok <aland@freeradius.org>
Mon, 5 Apr 2021 13:15:21 +0000 (09:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 5 Apr 2021 13:15:21 +0000 (09:15 -0400)
which bypasses the normal logic of proxy_new_listener(), etc.

src/main/process.c

index 63c924ead5536540d8e2601205d551ceeea6cf32..200e67a93e12782ec30312143bf8a4fe361db63b 100644 (file)
@@ -2316,6 +2316,9 @@ static int insert_into_proxy_hash(REQUEST *request)
        int tries;
        bool success = false;
        void *proxy_listener;
+#ifdef WITH_COA_TUNNEL
+       bool reverse_coa = request->proxy_listener && (request->proxy_listener->type != RAD_LISTEN_PROXY);
+#endif
 
        VERIFY_REQUEST(request);
 
@@ -2325,7 +2328,7 @@ static int insert_into_proxy_hash(REQUEST *request)
 
 
        PTHREAD_MUTEX_LOCK(&proxy_mutex);
-       proxy_listener = NULL;
+       proxy_listener = request->proxy_listener; /* may or may not be NULL */
        request->num_proxied_requests = 1;
        request->num_proxied_responses = 0;
 
@@ -2339,6 +2342,21 @@ static int insert_into_proxy_hash(REQUEST *request)
                                                  &request->proxy, &proxy_listener);
                if (success) break;
 
+#ifdef WITH_COA_TUNNEL
+               /*
+                *      Can't allocate an ID here, try to grab another
+                *      listener by key.
+                */
+               if (reverse_coa) {
+                       rad_assert(request->proxy_listener != NULL);
+
+                       PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
+                       if (listen_coa_find(request, request->proxy_listener->key) < 0) break;
+                       PTHREAD_MUTEX_LOCK(&proxy_mutex);
+                       continue;
+               }
+#endif
+
                if (tries > 0) continue; /* try opening new socket only once */
 
 #ifdef HAVE_PTHREAD_H