File 0310-erts-tcp-send-should-return-error-closed.patch of Package erlang

From 553896346c987d27958adc392940a3a197bbcdc4 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 18 Oct 2017 11:46:27 +0200
Subject: [PATCH] erts: tcp send should return {error,closed}

In the scenario where a gen_tcp:recv/2 detected an
error, the next gen_tcp:send should get a closed
error and not a enotconn error as was the case before.
---
 erts/emulator/drivers/common/inet_drv.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 7b1f4a0e9c..767fec3c98 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -9813,6 +9813,12 @@ static int tcp_recv_closed(tcp_descriptor* desc)
 	set_busy_port(desc->inet.port, 0);
 	inet_reply_error_am(INETP(desc), am_closed);
 	DEBUGF(("tcp_recv_closed(%ld): busy reply 'closed'\r\n", port));
+    } else {
+        /* No blocking send op to reply to right now.
+         * If next op is a send, make sure it returns {error,closed}
+         * rather than {error,enotconn}.
+         */
+        desc->tcp_add_flags |= TCP_ADDF_DELAYED_CLOSE_SEND;
     }
     if (!desc->inet.active) {
 	/* We must cancel any timer here ! */
-- 
2.16.3

openSUSE Build Service is sponsored by