Skip to content
Extraits de code Groupes Projets
Vérifiée Valider c818b8ab rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Cleaning the startup

parent c57466c1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!87Resolve "Segfault on exit"
......@@ -60,22 +60,21 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
normal_launch:
LOG_INFO("Lektor launched by user %s (shell: %s, home: %s)", pw->pw_name, pw->pw_shell, pw->pw_dir);
LOG_INFO_SCT("GENERAL", "Lektor launched by user %s (shell: %s, home: %s)",
pw->pw_name, pw->pw_shell, pw->pw_dir);
reg_set(server_reg);
mthread_init();
pthread_create(&th, NULL, mthread_main, NULL);
if (read_self_exe(exe, PATH_MAX))
LOG_WARN_SCT("GENERAL", "%s", "Failed to read self executable path, restart may not work");
LOG_WARN_SCT("GENERAL", "%s", "Failed to read self executable path, "
"restart may not work");
executable_name = exe;
/* Init the server */
char *memory = (char *) safe_malloc((2 * PATH_MAX + HOST_NAME_MAX + 3) * sizeof(char));
RETURN_UNLESS(memory, "Out of memory", 5);
struct lkt_state srv;
int autoclear, check_exclusive = 1;
char *const db_path = safe_malloc(PATH_MAX * sizeof(char));
char *const kara_dir = safe_malloc(PATH_MAX * sizeof(char));
char *db_path = safe_malloc(PATH_MAX * sizeof(char));
char *kara_dir = safe_malloc(PATH_MAX * sizeof(char));
char conf_file[PATH_MAX];
memset(&srv, 0, sizeof(struct lkt_state));
......@@ -85,14 +84,14 @@ normal_launch:
RETURN_IF (config_new(srv.db, conf_file), "Failed to read configuration file", 1);
/* Finish to initialize. */
RETURN_UNLESS(database_config_get_text(srv.db, "database", "db_path", db_path, PATH_MAX), "Cfg error", 2);
database_config_get_text(srv.db, "database", "db_path", db_path, PATH_MAX);
RETURN_UNLESS(database_open(srv.db, db_path, check_exclusive), "Can't open database", 1);
/* Read the configuration. */
RETURN_UNLESS(database_config_get_int (srv.db, "player", "autoclear", &autoclear), "Cfg error", 2);
RETURN_UNLESS(database_config_get_text(srv.db, "database", "kara_dir", kara_dir, PATH_MAX), "Cfg error", 2);
RETURN_UNLESS(database_config_get_text(srv.db, "server", "host", srv.host, HOST_NAME_MAX), "Cfg error", 2);
RETURN_UNLESS(database_config_get_text(srv.db, "server", "port", srv.port, 5), "Cfg error", 2);
/* Read the configuration. We already know that the config is valid */
database_config_get_int (srv.db, "player", "autoclear", &autoclear);
database_config_get_text(srv.db, "database", "kara_dir", kara_dir, PATH_MAX);
database_config_get_text(srv.db, "server", "host", srv.host, HOST_NAME_MAX);
database_config_get_text(srv.db, "server", "port", srv.port, 5);
if (kara_dir[strlen(kara_dir) - 1] != '/')
strncat(kara_dir, "/", PATH_MAX - 1);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter