Mercurial > dovecot > core-2.2
comparison src/director/director-connection.c @ 16621:5ef62caea61b
director: Update existing users' timestamps during handshake.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 29 Jul 2013 22:49:17 +0300 |
parents | 9b8b5ce6ecb0 |
children | a6736e42301e |
comparison
equal
deleted
inserted
replaced
16620:366024103c09 | 16621:5ef62caea61b |
---|---|
117 unsigned int handshake_sending_hosts:1; | 117 unsigned int handshake_sending_hosts:1; |
118 unsigned int ping_waiting:1; | 118 unsigned int ping_waiting:1; |
119 unsigned int synced:1; | 119 unsigned int synced:1; |
120 unsigned int wrong_host:1; | 120 unsigned int wrong_host:1; |
121 unsigned int verifying_left:1; | 121 unsigned int verifying_left:1; |
122 unsigned int users_unsorted:1; | |
122 }; | 123 }; |
123 | 124 |
124 static void director_connection_disconnected(struct director_connection **conn); | 125 static void director_connection_disconnected(struct director_connection **conn); |
125 static void director_connection_reconnect(struct director_connection **conn, | 126 static void director_connection_reconnect(struct director_connection **conn, |
126 const char *reason); | 127 const char *reason); |
576 return FALSE; | 577 return FALSE; |
577 } | 578 } |
578 | 579 |
579 (void)director_user_refresh(conn, username_hash, host, | 580 (void)director_user_refresh(conn, username_hash, host, |
580 timestamp, weak, &user); | 581 timestamp, weak, &user); |
582 if (user->timestamp < timestamp) { | |
583 conn->users_unsorted = TRUE; | |
584 user->timestamp = timestamp; | |
585 } | |
581 return TRUE; | 586 return TRUE; |
582 } | 587 } |
583 | 588 |
584 static bool | 589 static bool |
585 director_cmd_user(struct director_connection *conn, | 590 director_cmd_user(struct director_connection *conn, |
972 static bool director_handshake_cmd_done(struct director_connection *conn) | 977 static bool director_handshake_cmd_done(struct director_connection *conn) |
973 { | 978 { |
974 struct director *dir = conn->dir; | 979 struct director *dir = conn->dir; |
975 unsigned int handshake_secs = time(NULL) - conn->created; | 980 unsigned int handshake_secs = time(NULL) - conn->created; |
976 string_t *str; | 981 string_t *str; |
982 | |
983 if (conn->users_unsorted && conn->user_iter == NULL) { | |
984 /* we sent our user list before receiving remote's */ | |
985 conn->users_unsorted = FALSE; | |
986 user_directory_sort(conn->dir->users); | |
987 } | |
977 | 988 |
978 if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS || director_debug) { | 989 if (handshake_secs >= DIRECTOR_HANDSHAKE_WARN_SECS || director_debug) { |
979 str = t_str_new(128); | 990 str = t_str_new(128); |
980 str_printfa(str, "director(%s): Handshake took %u secs, " | 991 str_printfa(str, "director(%s): Handshake took %u secs, " |
981 "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, | 992 "bytes in=%"PRIuUOFF_T" out=%"PRIuUOFF_T, |
1435 } | 1446 } |
1436 } | 1447 } |
1437 user_directory_iter_deinit(&conn->user_iter); | 1448 user_directory_iter_deinit(&conn->user_iter); |
1438 director_connection_send(conn, "DONE\n"); | 1449 director_connection_send(conn, "DONE\n"); |
1439 | 1450 |
1451 if (conn->users_unsorted && conn->handshake_received) { | |
1452 /* we received remote's list of users before sending ours */ | |
1453 conn->users_unsorted = FALSE; | |
1454 user_directory_sort(conn->dir->users); | |
1455 } | |
1456 | |
1440 ret = o_stream_flush(conn->output); | 1457 ret = o_stream_flush(conn->output); |
1441 timeout_reset(conn->to_ping); | 1458 timeout_reset(conn->to_ping); |
1442 return ret; | 1459 return ret; |
1443 } | 1460 } |
1444 | 1461 |