about summary refs log tree commit diff
path: root/src/engine/e_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/e_network.c')
-rw-r--r--src/engine/e_network.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/engine/e_network.c b/src/engine/e_network.c
index b523e73b..d4e41a08 100644
--- a/src/engine/e_network.c
+++ b/src/engine/e_network.c
@@ -355,7 +355,8 @@ static void conn_want_resend(NETCONNECTION *conn)
 
 static int conn_flush(NETCONNECTION *conn)
 {
-	if(!conn->construct.num_chunks && !conn->construct.flags)
+	int num_chunks = conn->construct.num_chunks;
+	if(!num_chunks && !conn->construct.flags)
 		return 0;
 	
 	conn->construct.ack = conn->ack;
@@ -364,7 +365,7 @@ static int conn_flush(NETCONNECTION *conn)
 	
 	/* clear construct so we can start building a new package */
 	mem_zero(&conn->construct, sizeof(conn->construct));
-	return 1;
+	return num_chunks;
 }
 
 /*NETCHUNKDATA *data*/
@@ -620,10 +621,13 @@ static int conn_update(NETCONNECTION *conn)
 	if(conn->state == NET_CONNSTATE_ONLINE)
 	{
 		if(time_get()-conn->last_send_time > time_freq()/2) /* flush connection after 250ms if needed */
-			if(conn_flush(conn))
+		{
+			int num_flushed_chunks = conn_flush(conn);
+			if(num_flushed_chunks)
 			{
-				dbg_msg("connection", "flushed connection due to timeout");
+				dbg_msg("connection", "flushed connection due to timeout. %d chunks.", num_flushed_chunks);
 			}
+		}
 			
 		if(time_get()-conn->last_send_time > time_freq())
 			conn_send_control(conn, NET_CTRLMSG_KEEPALIVE, 0, 0);
@@ -1044,6 +1048,11 @@ int netclient_state(NETCLIENT *c)
 	return NETSTATE_CONNECTING;
 }
 
+int netclient_flush(NETCLIENT *c)
+{
+	return conn_flush(&c->conn);
+}
+
 int netclient_gotproblems(NETCLIENT *c)
 {
 	if(time_get() - c->conn.last_recv_time > time_freq())