From a300c1277a77cafa314f41b16baaa003b96384ca Mon Sep 17 00:00:00 2001 From: Jonathan Xu Date: Wed, 7 Aug 2019 19:29:08 +0800 Subject: [PATCH] Minor bug fixes. - set HAVE_MYSQL macro when MariaDB is used. - fix a crash bug when wrong database is configured. --- configure.ac | 1 + server/seaf-server.c | 2 +- server/seafile-session.c | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 0795526..c6fef89 100644 --- a/configure.ac +++ b/configure.ac @@ -241,6 +241,7 @@ else AC_MSG_RESULT([${MYSQL_CFLAGS}]) AC_SUBST(MYSQL_CFLAGS) AC_SUBST(MYSQL_LIBS) + AC_DEFINE([HAVE_MYSQL], 1, [Define to 1 if MySQL support is enabled]) fi if test x${compile_python} = xyes; then diff --git a/server/seaf-server.c b/server/seaf-server.c index a2dac7a..b0a6f88 100644 --- a/server/seaf-server.c +++ b/server/seaf-server.c @@ -53,7 +53,7 @@ static void usage () #define SEAFILE_RPC_PIPE_NAME "seafile.sock" -static void start_rpc_service (char *seafile_dir) +static void start_rpc_service (const char *seafile_dir) { SearpcNamedPipeServer *rpc_server = NULL; char *pipe_path = NULL; diff --git a/server/seafile-session.c b/server/seafile-session.c index a9cd252..3a0e593 100644 --- a/server/seafile-session.c +++ b/server/seafile-session.c @@ -53,9 +53,6 @@ seafile_session_new(const char *central_config_dir, if (central_config_dir) { abs_central_config_dir = ccnet_expand_path (central_config_dir); } - config_file_path = g_build_filename( - abs_central_config_dir ? abs_central_config_dir : abs_seafile_dir, - "seafile.conf", NULL); if (checkdir_with_mkdir (abs_seafile_dir) < 0) { seaf_warning ("Config dir %s does not exist and is unable to create\n", @@ -69,12 +66,17 @@ seafile_session_new(const char *central_config_dir, goto onerror; } + config_file_path = g_build_filename( + abs_central_config_dir ? abs_central_config_dir : abs_seafile_dir, + "seafile.conf", NULL); + GError *error = NULL; config = g_key_file_new (); if (!g_key_file_load_from_file (config, config_file_path, G_KEY_FILE_NONE, &error)) { seaf_warning ("Failed to load config file.\n"); g_key_file_free (config); + g_free (config_file_path); goto onerror; } g_free (config_file_path); @@ -164,7 +166,6 @@ seafile_session_new(const char *central_config_dir, onerror: free (abs_seafile_dir); g_free (tmp_file_dir); - g_free (config_file_path); g_free (session); return NULL; }