]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Close director connection immediately when output buffer is full
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 25 Oct 2017 14:22:42 +0000 (17:22 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 1 Nov 2017 15:54:24 +0000 (17:54 +0200)
Only the ostream was closed, which didn't actually cause the disconnection
until the other side closed the connection.

src/director/director-connection.c

index 45a1f3291d39d28a63f5d222c83df51ade098947..e2c3ce6a541a5f3137ddb0a4c4ab87c6cc736bdc 100644 (file)
@@ -2255,6 +2255,11 @@ static void director_connection_reconnect(struct director_connection **_conn,
                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)
 {
@@ -2279,6 +2284,11 @@ void director_connection_send(struct director_connection *conn,
                                "disconnecting", conn->name);
                }
                o_stream_close(conn->output);
+               /* closing the stream when output buffer is full doesn't cause
+                  disconnection itself. */
+               timeout_remove(&conn->to_disconnect);
+               conn->to_disconnect =
+                       timeout_add_short(0, director_disconnect_write_error, conn);
        } else {
                conn->dir->ring_traffic_output += len;
        }