changeset 22624:f7e2f55e6e91

director: Close director connection immediately when output buffer is full Only the ostream was closed, which didn't actually cause the disconnection until the other side closed the connection.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 25 Oct 2017 17:22:42 +0300
parents f733d647ff82
children 2a8509a8a66e
files src/director/director-connection.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director-connection.c	Wed Oct 25 17:18:03 2017 +0300
+++ b/src/director/director-connection.c	Wed Oct 25 17:22:42 2017 +0300
@@ -2262,6 +2262,11 @@
 		director_connect(dir, "Reconnecting after error");
 }
 
+static void director_disconnect_write_error(struct director_connection *conn)
+{
+	director_connection_deinit(&conn, "write failure");
+}
+
 void director_connection_send(struct director_connection *conn,
 			      const char *data)
 {
@@ -2286,6 +2291,12 @@
 				"disconnecting", conn->name);
 		}
 		o_stream_close(conn->output);
+		/* closing the stream when output buffer is full doesn't cause
+		   disconnection itself. */
+		if (conn->to_disconnect != NULL)
+			timeout_remove(&conn->to_disconnect);
+		conn->to_disconnect =
+			timeout_add_short(0, director_disconnect_write_error, conn);
 	} else {
 		conn->dir->ring_traffic_output += len;
 	}