Skip to content

Commit d3d20c7

Browse files
committed
Connect TCP recv window handlers between in/out on sessions
1 parent ac3c07f commit d3d20c7

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

lib/microLB/micro_lb/balancer.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,29 @@ namespace microLB
411411
[&nodes = n, idx] () {
412412
nodes.close_session(idx);
413413
});
414+
415+
// get the actual TCP connections
416+
auto conn_in = dynamic_cast<net::tcp::Stream*>(incoming->bottom_transport())->tcp();
417+
assert(conn_in != nullptr);
418+
auto conn_out = dynamic_cast<net::tcp::Stream*>(outgoing->bottom_transport())->tcp();
419+
assert(conn_out != nullptr);
420+
421+
static const uint32_t sendq_max = 0x400000;
422+
// set recv window handlers
423+
conn_in->set_recv_wnd_getter(
424+
[conn_out] () -> uint32_t {
425+
auto sendq_size = conn_out->sendq_size();
426+
if (sendq_size == 0)
427+
printf("WARNING: Incoming reports sendq size: %u\n", sendq_size);
428+
return sendq_max - sendq_size;
429+
});
430+
conn_out->set_recv_wnd_getter(
431+
[conn_in] () -> uint32_t {
432+
auto sendq_size = conn_in->sendq_size();
433+
if (sendq_size == 0)
434+
printf("WARNING: Outgoing reports sendq size: %u\n", sendq_size);
435+
return sendq_max - sendq_size;
436+
});
414437
}
415438
bool Session::is_alive() const {
416439
return incoming != nullptr;

0 commit comments

Comments
 (0)