director.h revision cf9d67e4a9bfee31cf3be05244555d51a3d1b9fe
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainentypedef void director_state_change_callback_t(struct director *dir);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* originating director for this change. keep ip/port here separately,
a0d34d3982507f513a9d800082481e9faeb9a943Timo Sirainen because by the time its sync comes, the director itself may have
a0d34d3982507f513a9d800082481e9faeb9a943Timo Sirainen already been removed. */
e6d7d19c328e7043ad35d5a52c1617bde915a16fTimo Sirainen unsigned int port;
d7095f3a4466fbb78b2d5eb3d322bc15a5b0ab1fTimo Sirainen /* highest change sequence from this director */
153de7823e64c67678b3fc95719c41a8ec5b864dTimo Sirainen unsigned int seq;
d7095f3a4466fbb78b2d5eb3d322bc15a5b0ab1fTimo Sirainen /* IP and port of this director. self_host->ip/port must equal these. */
9315dd69233d554452df0c12bc57002d2042a8f4Timo Sirainen /* temporary user -> host associations */
153de7823e64c67678b3fc95719c41a8ec5b864dTimo Sirainen /* these requests are waiting for directors to be in synced */
9315dd69233d554452df0c12bc57002d2042a8f4Timo Sirainen ARRAY_DEFINE(pending_requests, struct director_request *);
9315dd69233d554452df0c12bc57002d2042a8f4Timo Sirainen director_state_change_callback_t *state_change_callback;
41bb0aa8e357876bc9a1916a37c9e3e78e5f8185Timo Sirainen /* director hosts are sorted by IP (and port) */
538c58fc95200fcc5e91abdda8b912b574a2f968Timo Sirainen ARRAY_DEFINE(dir_hosts, struct director_host *);
bbf796c17f02538058d7559bfe96d677e5b55015Timo Sirainen /* this array contains host changes done by directors.
8aacc9e7c84f8376822823ec98c2f551d4919b2eTimo Sirainen while it's non-empty, new user mappings can't be added, because
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen different directors may see different hosts. SYNC events remove
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen these changes. */
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen ARRAY_DEFINE(desynced_host_changes, struct director_host_change);
d482b35af87f5fd872bad007da0475813a401a49Timo Sirainen /* director ring handshaking is complete.
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen director can start serving clients. */
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen/* Create a new director. If listen_ip specifies an actual IP, it's used with
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen listen_port for finding ourself from the director_servers setting.
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen listen_port is used regardless by director_host_add_from_string() for hosts
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen without specified port. */
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainendirector_init(const struct director_settings *set,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen const struct ip_addr *listen_ip, unsigned int listen_port,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen/* Start connecting to other directors */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid director_set_ring_handshaked(struct director *dir);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid director_set_state_changed(struct director *dir);
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainenvoid director_update_host(struct director *dir, struct director_host *src,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainenvoid director_remove_host(struct director *dir, struct director_host *src,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid director_update_user(struct director *dir, struct director_host *src,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen/* Send data to all directors using both left and right connections
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen (unless they're the same). */
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainenvoid director_update_send(struct director *dir, struct director_host *src,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen const char *data);
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainenint director_connect_host(struct director *dir, struct director_host *host);