director.c revision a93c909cfa1139226891d198dc6f7a7c98509b49
951N/A/* Copyright (c) 2010-2015 Dovecot authors, see the included COPYING file */ 951N/A /* Reset timestamp so that director_connect() won't skip this host 951N/A while we're still trying to connect to it */ 951N/A /* self, with some removed hosts */ 951N/A /* don't assume we're alone until we've attempted to connect 951N/A to others for a while */ 951N/A /* reset all failures and try again */ 951N/A /* try to connect to first working server on our right side. 951N/A the left side is supposed to connect to us. */ 951N/A /* connection failed recently, don't try retrying here */ 951N/A /* the director recently sent invalid protocol data, 951N/A don't try retrying yet */ 951N/A /* we're the only one */ 951N/A "we must be the only director left");
951N/A /* since we couldn't connect to it, 951N/A it must have failed recently */ 951N/A "This connection is dead?");
951N/A "continuing delayed requests");
951N/A /* all directors have been removed, try again later */ 951N/A /* the connection hasn't finished sync yet. 951N/A keep this timeout for now. */ 951N/A "(syncing took %d secs, hosts_hash=%u)",
951N/A /* try to reconnect to preferred host later */ 951N/A /* only minor_version>0 supports extra parameters */ 951N/A /* ping our connections in case either of them are hanging. 951N/A if they are, we want to know it fast. */ 951N/A /* send a new SYNC in case the previous one got dropped */ 951N/A /* we're synced again when we receive this SYNC back */ 951N/A /* we're alone. if we're already synced, 951N/A don't become unsynced. */ 951N/A /* send PINGs to our connections more rapidly until we've synced again. 951N/A if the connection has actually died, we don't need to wait (and 951N/A delay requests) for as long to detect it */ 951N/A /* others will just disconnect us */ 951N/A /* mark the host as removed and fully remove it later. this delay is 951N/A needed, because the removal may trigger director reconnections, 951N/A which may send the director back and we don't want to re-add it */ 951N/A /* disconnect any connections to the host */ 951N/A i_error(
"Ring has directors that don't support tags - removing host %s with tag '%s'",
951N/A i_error(
"Ring has directors that support mixed versions of tags - removing host %s with tag '%s'",
951N/A /* add any further version checks here - these directors ignore 951N/A any extra unknown arguments */ 951N/A /* update state in case this is the first mail host being added */ 951N/A "down=%d last_updown_change=%ld (hosts_hash=%u)",
951N/A /* mark the host desynced until ring is synced again. except if we're 951N/A alone in the ring that never happens. */ 951N/A "HOST-REMOVE\t%s\t%u\t%u\t%s\n",
951N/A "HOST-FLUSH\t%s\t%u\t%u\t%s\n",
951N/A /* only two directors in this ring and we're forwarding 951N/A USER-WEAK from one director back to itself via another 951N/A so it sees we've received it. we can't use 951N/A director_update_send() for this, because it doesn't send 951N/A data back to the source. */ 951N/A /* wait for a while for the kills to finish in the backend server, 951N/A so there are no longer any processes running for the user before we 951N/A start letting new in connections to the new server. */ 951N/A /* we can't really do anything but continue anyway */ 951N/A /* 1. move this user's host, and set its "killing" flag to delay all of 951N/A its future connections until all directors have killed the 951N/A connections and notified us about it. 951N/A 2. tell the other directors about the move 951N/A 3. once user kill callback is called, tell the other directors 951N/A with USER-KILLED that we're done killing the user. 951N/A 4. when some director gets a duplicate USER-KILLED, it's 951N/A responsible for notifying all directors that user is completely 951N/A 5. after receiving USER-KILLED-EVERYWHERE notification, 951N/A new connections are again allowed for the user. 951N/A /* user is already in this host */ 951N/A "USER-MOVE\t%s\t%u\t%u\t%u\t%s\n",
"USER-KILLED-EVERYWHERE\t%s\t%u\t%u\t%u\n",
/* we may get called to here from various places. use a timeout to make sure the state callback is called with a clean state. */