# HG changeset patch # User Timo Sirainen # Date 1508941362 -10800 # Node ID f7e2f55e6e918fbc1071500d79463654a94573b4 # Parent f733d647ff820f8d1046045250fa29b96f1a0cd5 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. diff -r f733d647ff82 -r f7e2f55e6e91 src/director/director-connection.c --- 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; }