From 4c3d762fd6da36cfe877506b74820850eef9f706 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Tue, 11 May 2010 00:34:33 +0200 Subject: Fix aborts due to transmit window overflow c0b02222 made conn->sendable unsigned. If the device reduces the window after we've sent too much data already, it can become negative, overflow, and cause connection aborts when we send too much data. Fix this by checking for this condition and setting conn->sendable to 0. Thanks to Thomas Jost and Nikias Bassen for debugging this issue. --- daemon/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/device.c b/daemon/device.c index acedbdf..684e009 100644 --- a/daemon/device.c +++ b/daemon/device.c @@ -322,7 +322,12 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien static void update_connection(struct mux_connection *conn) { - conn->sendable = conn->rx_win - (conn->tx_seq - conn->rx_ack); + uint32_t sent = conn->tx_seq - conn->rx_ack; + + if(conn->rx_win > sent) + conn->sendable = conn->rx_win - sent; + else + conn->sendable = 0; if(conn->sendable > conn->ob_capacity) conn->sendable = conn->ob_capacity; -- cgit v1.1-32-gdbae