Commit 0e30010d authored by jan.koester's avatar jan.koester
Browse files

test

parent f50fe8e8
Loading
Loading
Loading
Loading
+30 −8
Changes for src/quic.cpp: 30 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -43,12 +43,7 @@
#include <cstdio>
#include <cmath>

#define QUIC_DBG(fmt, ...) do { \
    if (getenv("QUIC_TRACE")) { \
        fprintf(stderr, "[%.6f] " fmt "\n", \
                std::chrono::duration<double>(std::chrono::steady_clock::now().time_since_epoch()).count(), ##__VA_ARGS__); \
    } \
} while(0)
#define QUIC_DBG(fmt, ...) do { } while(0)

namespace netplus {

@@ -3823,7 +3818,6 @@ void quic::processStreamFrame(const uint8_t* data, size_t len, size_t& offset) {
    }


    
    // Queue stream dispatch — will be invoked OUTSIDE _quic_mutex
    // so that long-running callbacks (e.g. import) don't block PING ACKs
    // and don't deadlock when the callback calls sendStreamData/flush_out.
@@ -5710,7 +5704,7 @@ void quic::pumpIncoming() {
    }

    for (auto& [t, pkts] : grouped) {
        std::lock_guard<std::recursive_mutex> target_lock(t->quic_mtx());
        std::unique_lock<std::recursive_mutex> target_lock(t->quic_mtx());
        t->processApplicationPacketsBatch(pkts);
        // The self case's pending flow-control frames are flushed by the
        // unconditional block below (operating on `this`'s own state);
@@ -5727,6 +5721,34 @@ void quic::pumpIncoming() {
            }
            t->pmtudTick();
        }

        // Dispatch stream callbacks for routed (sibling) connections too —
        // same as accept()'s flush_pending_app. Without this, a sibling
        // connection that reaches recv_complete while its data happens to
        // be routed through THIS call (instead of through its own accept()
        // call) leaves its completed stream sitting in _pending_dispatches
        // forever: the callback — and therefore any echo/response it would
        // trigger — never fires, until some later, unrelated packet
        // happens to route that connection through accept() instead. Only
        // reachable for `t != this`: a self-targeted entry here would need
        // a shared_ptr to `this`, which callers of pumpIncoming() don't
        // supply (quic has no enable_shared_from_this) — not a gap in
        // practice, since `this` is always mid-send when this function
        // runs, and mid-send state doesn't populate its own
        // _pending_dispatches (that only happens from receiving stream
        // data, not from processing ACKs for what was just sent).
        if (t != this && !t->_pending_dispatches.empty()) {
            auto pin_it = std::find_if(pins.begin(), pins.end(),
                [&](const std::shared_ptr<quic>& p) { return p.get() == t; });
            if (pin_it != pins.end()) {
                std::shared_ptr<quic> target_pin = *pin_it;
                std::vector<PendingDispatch> dispatches = std::move(t->_pending_dispatches);
                t->_pending_dispatches.clear();
                target_lock.unlock();
                quic::scheduleDispatches(target_pin, std::move(dispatches));
                target_lock.lock();
            }
        }
    }

    // Flush own pending flow control frames, and check for lost packets to