Skip to content

Commit

Permalink
director: Close director connection immediately when output buffer is…
Browse files Browse the repository at this point in the history
… full

Only the ostream was closed, which didn't actually cause the disconnection
until the other side closed the connection.
  • Loading branch information
sirainen committed Nov 7, 2017
1 parent f077ace commit 750a933
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/director/director-connection.c
Expand Up @@ -2262,6 +2262,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)
{
Expand All @@ -2286,6 +2291,12 @@ 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. */
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;
}
Expand Down

0 comments on commit 750a933

Please sign in to comment.