]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move "set priority or discard"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 14 Jun 2023 02:20:51 +0000 (22:20 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 14 Jun 2023 02:20:51 +0000 (22:20 -0400)
to just before "send packet to worker"

src/lib/io/network.c

index dc06fd8ac0e7c937c33f36f308a1b8b5aecbbaee..df8942a3d8898794ca2b4073e19931697e6b21a4 100644 (file)
@@ -922,32 +922,6 @@ next_message:
        }
        s->cd = NULL;
 
-       /*
-        *      Set the priority.  Which incidentally also checks if
-        *      we're allowed to read this particular kind of packet.
-        *
-        *      That check is because the app_io handlers just read
-        *      packets, and don't really have access to the parent
-        *      "list of allowed packet types".  So we have to do the
-        *      work here in a callback.
-        *
-        *      That should probably be fixed...
-        */
-       if (s->listen->app->priority) {
-               int priority;
-
-               priority = s->listen->app->priority(s->listen->app_instance, cd->m.data, data_size);
-               if (priority <= 0) {
-                       talloc_free(cd->packet_ctx); /* not sure what else to do here */
-                       fr_message_done(&cd->m);
-                       nr->stats.dropped++;
-                       s->stats.dropped++;
-                       goto done;
-               }
-
-               cd->priority = priority;
-       }
-
        DEBUG3("Read %zd byte(s) from FD %u", data_size, sockfd);
        nr->stats.in++;
        s->stats.in++;
@@ -990,7 +964,28 @@ next_message:
                }
        }
 
+       /*
+        *      Set the priority.  Which incidentally also checks if
+        *      we're allowed to read this particular kind of packet.
+        *
+        *      That check is because the app_io handlers just read
+        *      packets, and don't really have access to the parent
+        *      "list of allowed packet types".  So we have to do the
+        *      work here in a callback.
+        *
+        *      That should probably be fixed...
+        */
+       if (s->listen->app->priority) {
+               int priority;
+
+               priority = s->listen->app->priority(s->listen->app_instance, cd->m.data, data_size);
+               if (priority <= 0) goto discard;
+
+               cd->priority = priority;
+       }
+
        if (fr_network_send_request(nr, cd) < 0) {
+       discard:
                talloc_free(cd->packet_ctx); /* not sure what else to do here */
                fr_message_done(&cd->m);
                nr->stats.dropped++;