diff --git a/src/streams/netstream.cpp b/src/streams/netstream.cpp index 4e873847a9766ee060b0c22fbd94367333e7060e..36e4470f1a7aaf452f95470797e6bdeacf3c0470 100644 --- a/src/streams/netstream.cpp +++ b/src/streams/netstream.cpp @@ -224,7 +224,7 @@ void Net::_earlyProcessPacket(ftl::net::Peer *p, int16_t ttimeoff, const StreamP // Manage recuring requests if (!host_ && spkt.channel == Channel::kEndFrame && localFrame.frameset() < tally_.size()) { // Are we close to reaching the end of our frames request? - if (tally_[localFrame.frameset()] <= 5) { + if (tally_[localFrame.frameset()] <= frames_to_request_ / 2) { // Yes, so send new requests for (const auto f : enabled(localFrame.frameset())) { const auto &sel = enabledChannels(f); @@ -251,7 +251,6 @@ void Net::_processPacket(ftl::net::Peer *p, int16_t ttimeoff, const StreamPacket spkt.hint_capability = 0; spkt.hint_source_total = 0; spkt.version = 4; - if (p) spkt.hint_peerid = p->localID(); bool isRequest = host_ && pkt.data.size() == 0 && (spkt.flags & ftl::protocol::kFlagRequest); @@ -355,7 +354,7 @@ void Net::_run() { int64_t pts = current->packets.first.timestamp - state->base_pkt_ts_ + buffering_; // Should the packet be dispatched yet - if (pts == ats) { + if (pts == ats && !current->done) { framePackets.push_back(&(*current)); if (current->packets.first.channel == Channel::kEndFrame) { @@ -459,8 +458,9 @@ bool Net::begin() { // TODO(Nick): This buffer could be faster? auto &buf = state->buffer.emplace_back(); buf.packets.first = spkt_raw; + buf.packets.first.hint_peerid = p.localID(); buf.packets.second = std::move(pkt); - buf.peer = &p; + buf.peer = nullptr; buf.done = false; } else { _processPacket(&p, ttimeoff, spkt_raw, pkt); diff --git a/src/streams/netstream.hpp b/src/streams/netstream.hpp index 89b22cac48a95f82ce6b2f677bd3776e2222866e..fb2db0e551b1ac5fcb033a94bab1c4c706049be8 100644 --- a/src/streams/netstream.hpp +++ b/src/streams/netstream.hpp @@ -80,7 +80,7 @@ class Net : public Stream { static void installRPC(ftl::net::Universe *net); - static constexpr int kFramesToRequest = 30; + static constexpr int kFramesToRequest = 80; // Unit test support virtual void hasPosted(const ftl::protocol::StreamPacket &, const ftl::protocol::DataPacket &) {} diff --git a/test/stream_integration.cpp b/test/stream_integration.cpp index 6cb9352f725ca31f15a634f5c3855e65d2f6ff88..3fdfaf514e9ea50cdc2ebb52c3c43fbce1cb6cbb 100644 --- a/test/stream_integration.cpp +++ b/test/stream_integration.cpp @@ -110,6 +110,8 @@ TEST_CASE("TCP Stream", "[net]") { return true; }); + s2->setProperty(ftl::protocol::StreamProperty::kRequestSize, 30); + s1->begin(); s2->begin();