# HG changeset patch # User Timo Sirainen # Date 1477335483 -10800 # Node ID 3e6f922c2322c5fa359b3413d8ddb9339182ffd9 # Parent d653bcdff8a2aac484df4845de2d73fce7b1de08 director: If SYNCs are received during handshake, send them later. This fixes delays during handshake: Error: Ring SYNC appears to have got lost, resending diff -r d653bcdff8a2 -r 3e6f922c2322 src/director/director-connection.c --- a/src/director/director-connection.c Mon Oct 24 20:21:36 2016 +0300 +++ b/src/director/director-connection.c Mon Oct 24 21:58:03 2016 +0300 @@ -316,6 +316,25 @@ return FALSE; } +static void director_send_delayed_syncs(struct director *dir) +{ + struct director_host *const *hostp; + + i_assert(dir->right != NULL); + + dir_debug("director(%s): Sending delayed SYNCs", dir->right->name); + array_foreach(&dir->dir_hosts, hostp) { + if ((*hostp)->delayed_sync_seq == 0) + continue; + + director_sync_send(dir, *hostp, (*hostp)->delayed_sync_seq, + (*hostp)->delayed_sync_minor_version, + (*hostp)->delayed_sync_timestamp, + (*hostp)->delayed_sync_hosts_hash); + (*hostp)->delayed_sync_seq = 0; + } +} + static bool director_connection_assign_right(struct director_connection *conn) { struct director *dir = conn->dir; @@ -343,6 +362,7 @@ i_free(conn->name); conn->name = i_strdup_printf("%s/right", conn->host->name); director_connection_assigned(conn); + director_send_delayed_syncs(dir); return TRUE; } @@ -1422,6 +1442,13 @@ /* forward it to the connection on right */ director_sync_send(dir, host, seq, minor_version, timestamp, hosts_hash); + } else { + dir_debug("director(%s): We have no right connection - " + "delay replying to SYNC until finished", conn->name); + host->delayed_sync_seq = seq; + host->delayed_sync_minor_version = minor_version; + host->delayed_sync_timestamp = timestamp; + host->delayed_sync_hosts_hash = hosts_hash; } } return TRUE; diff -r d653bcdff8a2 -r 3e6f922c2322 src/director/director-host.h --- a/src/director/director-host.h Mon Oct 24 20:21:36 2016 +0300 +++ b/src/director/director-host.h Mon Oct 24 21:58:03 2016 +0300 @@ -30,6 +30,14 @@ /* Last time host was detected to be down */ time_t last_network_failure; time_t last_protocol_failure; + + /* When we finish getting a right connection, send a SYNC with these + parameters (if delayed_sync_seq != 0) */ + uint32_t delayed_sync_seq; + unsigned int delayed_sync_minor_version; + unsigned int delayed_sync_timestamp; + unsigned int delayed_sync_hosts_hash; + /* we are this director */ unsigned int self:1; unsigned int removed:1;