Skip to content

Commit 0290def

Browse files
committed
tcp: Various tweaks to TCP packet offering
1 parent 508e9de commit 0290def

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

api/net/tcp/tcp.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "packet.hpp"
2727

2828
#include <map> // connections, listeners
29-
#include <queue> // writeq
29+
#include <deque> // writeq
3030
#include <net/inet.hpp>
3131
#include <net/socket.hpp>
3232
#include <net/port_util.hpp>
@@ -710,7 +710,7 @@ namespace net {
710710
*
711711
* @param[in] <unnamed> A ptr to a Connection
712712
*/
713-
void queue_offer(tcp::Connection_ptr);
713+
void queue_offer(tcp::Connection&);
714714

715715
/**
716716
* @brief Force the TCP to process the it's queue with the current amount of available packets.

src/net/tcp/connection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ void Connection::offer(size_t& packets)
199199
debug2("<Connection::offer> Finished working offer with [%u] packets left and a queue of (%u) with a usable window of %i\n",
200200
packets, writeq.size(), usable_window());
201201

202-
if(can_send() and not queued_)
202+
if (this->can_send() and not this->is_queued())
203203
{
204-
host_.queue_offer(retrieve_shared());
204+
host_.queue_offer(*this);
205205
}
206206
}
207207

src/net/tcp/tcp.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,24 @@ void TCP::request_offer(Connection& conn) {
489489
debug2("<TCP::request_offer> %s requestin offer: uw=%u rem=%u\n",
490490
conn.to_string().c_str(), conn.usable_window(), conn.sendq_remaining());
491491

492-
conn.offer(packets);
492+
if (packets > 0) {
493+
conn.offer(packets);
494+
}
493495
}
494496

495-
void TCP::queue_offer(Connection_ptr conn)
497+
void TCP::queue_offer(Connection& conn)
496498
{
497-
if(not conn->is_queued() and conn->can_send())
499+
if(not conn.is_queued() and conn.can_send())
498500
{
499-
debug("<TCP::queue_offer> %s queued\n", conn->to_string().c_str());
500-
writeq.push_back(conn);
501-
conn->set_queued(true);
501+
try {
502+
debug("<TCP::queue_offer> %s queued\n", conn.to_string().c_str());
503+
writeq.push_back(conn.retrieve_shared());
504+
conn.set_queued(true);
505+
}
506+
catch (std::exception& e) {
507+
printf("ERROR: Could not find connection for %p: %s\n",
508+
&conn, conn.to_string().c_str());
509+
throw;
510+
}
502511
}
503512
}

0 commit comments

Comments
 (0)