user-directory.h revision 6af8cc0573832465c621bcd91634e15461e8bf58
#ifndef USER_DIRECTORY_H
#define USER_DIRECTORY_H
enum user_kill_state {
/* User isn't being killed */
/* We're still killing the user's connections */
/* Like above, but our left side already announced it was finished
with killing its user connections */
/* We're done killing, but we have to wait for the left side to
finish killing its user connections before sending USER-KILLED to
our right side */
/* We're done killing, but waiting for USER-KILLED-EVERYWHERE
notification until this state gets reset. */
/* Waiting for the flush socket to finish. */
/* Wait for a while for the user connections to actually die. Note that
only at this stage we can be sure that all the directors know about
the user move (although it could be earlier if we added a new
USER-MOVED notification). */
/* NOTE: remember to update also user_kill_state_names[] */
};
struct user {
/* sorted by time */
/* first 32 bits of MD5(username). collisions are quite unlikely, but
even if they happen it doesn't matter - the users are just
redirected to same server */
unsigned int username_hash;
unsigned int timestamp;
/* Move timeout to make sure user's connections won't silently hang
indefinitely if there is some trouble moving it. */
/* If not USER_KILL_STATE_NONE, don't allow new connections until all
directors have killed the user's connections. */
enum user_kill_state kill_state;
/* TRUE, if the user's timestamp was close to being expired and we're
now doing a ring-wide sync for this user to make sure we don't
assign conflicting hosts to it */
bool weak:1;
/* TRUE, if this server initiated the user's kill. */
bool kill_is_self_initiated:1;
};
/* Create a new directory. Users are dropped if their time gets older
than timeout_secs. */
struct user_directory *
/* Returns the number of users currently in directory. */
/* Look up username from directory. Returns NULL if not found. */
unsigned int username_hash);
/* Add a user to directory and return it. */
struct user *
/* Refresh user's timestamp */
/* Remove all users that have pointers to given host */
/* Sort users based on the timestamp. This is called only after updating
timestamps based on remote director's user list after handshake. */
const char *username);
/* Iterate through users in the directory. It's safe to modify user directory
over. */
struct user_directory_iter *
#endif