]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker send_waiting(): be more defensive
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 24 Apr 2025 08:58:16 +0000 (10:58 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 24 Apr 2025 08:58:16 +0000 (10:58 +0200)
See the 6.x commit 7210f16e

daemon/worker.c

index 097608b60df09d94e0c117eeb83f8aab0d7b48c0..81fe02288fc8435818e37789fd6ed0cece022140 100644 (file)
@@ -923,7 +923,14 @@ static int send_waiting(struct session *session)
                        session_close(session);
                        break;
                }
-               session_waitinglist_pop(session, true);
+               // Let's be a bit defensive and check that nothing's changed before _pop()
+               // and recover if it has, as qr_task_send() is rather complex.
+               // TODO: fully analyze why the waitinglist could get empty here.
+               if (session_waitinglist_get(session) == t) {
+                       session_waitinglist_pop(session, true);
+               } else { // a normal assertion could kr_error_log() too much in some rarer cases
+                       VERBOSE_MSG(NULL, "soft assertion: waitinglist mismatch in send_waiting()\n");
+               }
        }
        return ret;
 }