[criu] libsoccr: ignore data in a sent queue, if a connect is closed

Submitted by Andrei Vagin on Oct. 6, 2017, 4:15 a.m.

Details

Message ID 20171006041509.16202-1-avagin@openvz.org
State New
Series "libsoccr: ignore data in a sent queue, if a connect is closed"
Headers show

Commit Message

Andrei Vagin Oct. 6, 2017, 4:15 a.m.
From: Andrei Vagin <avagin@virtuozzo.com>

If a connection was reseted, it can have some data in a sent queue,
a use can't read this data, so we can ignore them too.

https://jira.sw.ru/browse/PSBM-67026

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 soccr/soccr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch hide | download patch | download mbox

diff --git a/soccr/soccr.c b/soccr/soccr.c
index 48469aaab..bdf92d721 100644
--- a/soccr/soccr.c
+++ b/soccr/soccr.c
@@ -198,6 +198,18 @@  static int refresh_sk(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, str
 
 	data->unsq_len = size;
 
+	if (data->state == TCP_CLOSE) {
+		/* A connection could be reseted. In thise case a sent queue
+		 * may contain some data. A user can't read this data, so let's
+		 * ignore them. Otherwise we will need to add a logic whether
+		 * the send queue contains a fin packet or not and decide whether
+		 * a fin or reset packet has to be sent to restore a state
+		 */
+
+		data->unsq_len = 0;
+		data->outq_len = 0;
+	}
+
 	/* Don't account the fin packet. It doesn't countain real data. */
 	if ((1 << data->state) & (SNDQ_FIRST_FIN | SNDQ_SECOND_FIN)) {
 		if (data->outq_len)