]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Always mark trunk requests as complete when freeing query ctx
authorNick Porter <nick@portercomputing.co.uk>
Fri, 28 Jun 2024 09:43:12 +0000 (10:43 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 28 Jun 2024 10:21:54 +0000 (11:21 +0100)
Due to query_ctx being re-used multiple times when running transactions
(e.g. allocating IPs in sqlippool) it is possible for the current query
to not be submitted, but there still to be a trunk request associated
with the query_ctx.

src/modules/rlm_sql/sql.c

index 90ae00886a46846ccbd632a71c598dca0d2ab1e9..15239ca8c48308f538afda8fee38ff343e03c09f 100644 (file)
@@ -396,11 +396,12 @@ void rlm_sql_print_error(rlm_sql_t const *inst, request_t *request, fr_sql_query
  */
 static int fr_sql_query_free(fr_sql_query_t *to_free)
 {
-       if (to_free->status <= 0) return 0;
-       if (to_free->type == SQL_QUERY_SELECT) {
-               (to_free->inst->driver->sql_finish_select_query)(to_free, &to_free->inst->config);
-       } else {
-               (to_free->inst->driver->sql_finish_query)(to_free, &to_free->inst->config);
+       if (to_free->status > 0) {
+               if (to_free->type == SQL_QUERY_SELECT) {
+                       (to_free->inst->driver->sql_finish_select_query)(to_free, &to_free->inst->config);
+               } else {
+                       (to_free->inst->driver->sql_finish_query)(to_free, &to_free->inst->config);
+               }
        }
        if (to_free->treq) trunk_request_signal_complete(to_free->treq);
        return 0;