Changeset 178 for trunk/wifidog/src/conf.c
- Timestamp:
- 08/09/04 18:38:03 (9 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog/src/conf.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/conf.c
r176 r178 31 31 #include <syslog.h> 32 32 33 #include <pthread.h> 34 33 35 #include <string.h> 34 36 … … 43 45 * Holds the current configuration of the gateway */ 44 46 static s_config config; 47 48 /** @internal 49 * Mutex for the configuration file, used by the auth_servers related 50 * functions. */ 51 static pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER; 45 52 46 53 /** @internal … … 61 68 oGatewayPort, 62 69 oAuthServer, 70 oAuthServMaxTries, 63 71 oAuthservPath, 64 72 oAuthservLoginUrl, … … 86 94 { "gatewayport", oGatewayPort }, 87 95 { "authserver", oAuthServer }, 96 { "authservmaxtries", oAuthServMaxTries }, 88 97 { "authservpath", oAuthservPath }, 89 98 { "authservloginurl", oAuthservLoginUrl }, … … 125 134 config.gw_port = DEFAULT_GATEWAYPORT; 126 135 config.auth_servers = NULL; 136 config.authserv_maxtries = DEFAULT_AUTHSERVMAXTRIES; 127 137 config.authserv_path = strdup(DEFAULT_AUTHSERVPATH); 128 138 config.authserv_loginurl = NULL; … … 251 261 sscanf(p1, "%d", &config.httpdmaxconn); 252 262 break; 263 case oAuthServMaxTries: 264 sscanf(p1, "%d", &config.authserv_maxtries); 265 break; 253 266 case oAuthservPath: 254 267 free(config.authserv_path); … … 336 349 /** @internal 337 350 Register a new auth server. 351 352 @param host Hostname of the server 353 @param port Port of the server 338 354 */ 339 355 static void … … 368 384 debug(LOG_DEBUG, "Auth server added"); 369 385 } 386 387 /** 388 * This function returns the current (first auth_server) 389 */ 390 t_auth_serv * 391 get_auth_server(void) 392 { 393 394 /* This is as good as atomic */ 395 return config.auth_servers; 396 } 397 398 /** 399 * This function marks the current auth_server, if it matches the argument, 400 * as bad. Basically, the "bad" server becomes the last one on the list. 401 */ 402 void 403 mark_auth_server_bad(t_auth_serv *bad_server) 404 { 405 t_auth_serv *tmp; 406 407 /* lock mutex so two different threads both don't mark the same 408 * server as bad */ 409 pthread_mutex_lock(&config_mutex); 410 411 if (config.auth_servers == bad_server) { 412 /* Go to the last */ 413 for (tmp = config.auth_servers; tmp->next != NULL; tmp = tmp->next); 414 /* Set bad server as last */ 415 tmp->next = bad_server; 416 /* Remove bad server from start of list */ 417 config.auth_servers = bad_server->next; 418 /* Set the next pointe to NULL in the last element */ 419 bad_server->next = NULL; 420 } 421 422 pthread_mutex_unlock(&config_mutex); 423 }
