void mark_offline() { int before; int after; before = is_online(); time(&last_offline_time); after = is_online(); if (before != after) { debug(LOG_INFO, "ONLINE status became %s", (after ? "ON" : "OFF")); } /* If we're offline it definately means the auth server is offline */ mark_auth_offline(); }
/* Tries really hard to connect to an auth server. Returns a file descriptor, -1 on error */ int connect_auth_server() { int sockfd; LOCK_CONFIG(); sockfd = _connect_auth_server(0); UNLOCK_CONFIG(); if (sockfd == -1) { debug(LOG_ERR, "Failed to connect to any of the auth servers"); mark_auth_offline(); } else { debug(LOG_DEBUG, "Connected to auth server"); mark_auth_online(); } return (sockfd); }
/** in connect function emong added,for quickly find useable server */ int in_connect_auth_server(t_auth_serv *server) { int sockfd,level=0; s_config *config = config_get_config(); t_auth_serv *tmp_server; for (tmp_server = config->auth_servers; tmp_server; tmp_server = tmp_server->next) { if(tmp_server == server) //find it break; ++level; } LOCK_CONFIG(); sockfd = _connect_auth_server(level,0); UNLOCK_CONFIG(); if (sockfd == -1) { debug(LOG_ERR, "Failed to connect to any of the auth servers"); mark_auth_offline(); } else { debug(LOG_DEBUG, "Connected to auth server"); mark_auth_online(); } return (sockfd); }