Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop
it merges an updated upstream into a topic branch.
This commit is contained in:
@ -270,12 +270,14 @@ static void blockbuf_register(blockbuf_t* bb);
|
|||||||
static void blockbuf_unregister(blockbuf_t* bb);
|
static void blockbuf_unregister(blockbuf_t* bb);
|
||||||
static bool logfile_set_enabled(logfile_id_t id, bool val);
|
static bool logfile_set_enabled(logfile_id_t id, bool val);
|
||||||
static char* add_slash(char* str);
|
static char* add_slash(char* str);
|
||||||
static bool file_exists_and_is_writable(char* filename, bool* writable);
|
|
||||||
|
static bool check_file_and_path(
|
||||||
|
char* filename,
|
||||||
|
bool* nameconflict,
|
||||||
|
bool* writable);
|
||||||
|
|
||||||
static bool file_is_symlink(char* filename);
|
static bool file_is_symlink(char* filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* get_suffix_default(void)
|
const char* get_suffix_default(void)
|
||||||
{
|
{
|
||||||
return ".log";
|
return ".log";
|
||||||
@ -357,24 +359,28 @@ static bool logmanager_init_nomutex(
|
|||||||
fn->fn_state = UNINIT;
|
fn->fn_state = UNINIT;
|
||||||
fw->fwr_state = UNINIT;
|
fw->fwr_state = UNINIT;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set global variable
|
|
||||||
*/
|
|
||||||
lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles;
|
|
||||||
|
|
||||||
/** Initialize configuration including log file naming info */
|
/** Initialize configuration including log file naming info */
|
||||||
if (!fnames_conf_init(fn, argc, argv)) {
|
if (!fnames_conf_init(fn, argc, argv)) {
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize logfiles */
|
/** Initialize logfiles */
|
||||||
if(!logfiles_init(lm)) {
|
if(!logfiles_init(lm))
|
||||||
|
{
|
||||||
|
err = 1;
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set global variable
|
||||||
|
*/
|
||||||
|
lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles;
|
||||||
|
|
||||||
/** Initialize filewriter data and open the (first) log file(s)
|
/** Initialize filewriter data and open the (first) log file(s)
|
||||||
* for each log file type. */
|
* for each log file type. */
|
||||||
if (!filewriter_init(lm, fw, lm->lm_clientmes, lm->lm_logmes)) {
|
if (!filewriter_init(lm, fw, lm->lm_clientmes, lm->lm_logmes))
|
||||||
|
{
|
||||||
|
err = 1;
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +389,8 @@ static bool logmanager_init_nomutex(
|
|||||||
thr_filewriter_fun,
|
thr_filewriter_fun,
|
||||||
(void *)fw);
|
(void *)fw);
|
||||||
|
|
||||||
if ((err = skygw_thread_start(fw->fwr_thread)) != 0) {
|
if ((err = skygw_thread_start(fw->fwr_thread)) != 0)
|
||||||
|
{
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
}
|
}
|
||||||
/** Wait message from filewriter_thr */
|
/** Wait message from filewriter_thr */
|
||||||
@ -393,10 +400,11 @@ static bool logmanager_init_nomutex(
|
|||||||
lm->lm_enabled = true;
|
lm->lm_enabled = true;
|
||||||
|
|
||||||
return_succp:
|
return_succp:
|
||||||
if (err != 0) {
|
if (err != 0)
|
||||||
|
{
|
||||||
/** This releases memory of all created objects */
|
/** This releases memory of all created objects */
|
||||||
logmanager_done_nomutex();
|
logmanager_done_nomutex();
|
||||||
fprintf(stderr, "* Initializing logmanager failed.\n");
|
fprintf(stderr, "*\n* Error : Initializing log manager failed.\n*\n");
|
||||||
}
|
}
|
||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
@ -1769,7 +1777,7 @@ static bool logfiles_init(
|
|||||||
write_syslog);
|
write_syslog);
|
||||||
|
|
||||||
if (!succp) {
|
if (!succp) {
|
||||||
fprintf(stderr, "Initializing logfiles failed\n");
|
fprintf(stderr, "*\n* Error : Initializing log files failed.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lid <<= 1;
|
lid <<= 1;
|
||||||
@ -1917,9 +1925,10 @@ static char* add_slash(
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @node Check if the file exists in the local file system and if it does,
|
* @node Check if the path and file exist in the local file system and if they do,
|
||||||
* whether it is writable.
|
* check if they are accessible and writable.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* @param filename - <usage>
|
* @param filename - <usage>
|
||||||
@ -1928,55 +1937,91 @@ static char* add_slash(
|
|||||||
* @param writable - <usage>
|
* @param writable - <usage>
|
||||||
* <description>
|
* <description>
|
||||||
*
|
*
|
||||||
* @return
|
* @return true & writable if file exists and it is writable,
|
||||||
|
* true & not writable if file exists but it can't be written,
|
||||||
|
* false & writable if file doesn't exist but directory could be written, and
|
||||||
|
* false & not writable if directory can't be written.
|
||||||
*
|
*
|
||||||
*
|
* @details Note, that a space character is written to the end of file.
|
||||||
* @details Note, that an space character is written to the end of file.
|
|
||||||
* TODO: recall what was the reason for not succeeding with simply
|
* TODO: recall what was the reason for not succeeding with simply
|
||||||
* calling access, and fstat. vraa 26.11.13
|
* calling access, and fstat. vraa 26.11.13
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static bool file_exists_and_is_writable(
|
static bool check_file_and_path(
|
||||||
char* filename,
|
char* filename,
|
||||||
bool* writable)
|
bool* writable)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
bool exists = true;
|
bool exists;
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
{
|
{
|
||||||
exists = false;
|
exists = false;
|
||||||
|
*writable = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fd = open(filename, O_CREAT|O_EXCL, S_IRWXU);
|
fd = open(filename, O_CREAT|O_EXCL, S_IRWXU);
|
||||||
|
|
||||||
/** file exist */
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
/** File exists, check permission to read/write */
|
||||||
|
if (errno == EEXIST)
|
||||||
{
|
{
|
||||||
/** Open file and write a byte for test */
|
/** Open file and write a byte for test */
|
||||||
fd = open(filename, O_CREAT|O_RDWR, S_IRWXU|S_IRWXG);
|
fd = open(filename, O_CREAT|O_RDWR, S_IRWXU|S_IRWXG);
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"*\n* Error : Can't access %s due "
|
||||||
|
"to %s.\n",
|
||||||
|
filename,
|
||||||
|
strerror(errno));
|
||||||
|
*writable = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
char c = ' ';
|
char c = ' ';
|
||||||
if (write(fd, &c, 1) == 1)
|
if (write(fd, &c, 1) == 1)
|
||||||
{
|
{
|
||||||
*writable = true;
|
*writable = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"*\n* Error : Can't write to "
|
||||||
|
"%s due to %s.\n",
|
||||||
|
filename,
|
||||||
|
strerror(errno));
|
||||||
|
*writable = false;
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"*\n* Error : Can't access %s due to %s.\n",
|
||||||
|
filename,
|
||||||
|
strerror(errno));
|
||||||
|
exists = false;
|
||||||
|
*writable = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
exists = false;
|
exists = false;
|
||||||
|
*writable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool file_is_symlink(
|
static bool file_is_symlink(
|
||||||
char* filename)
|
char* filename)
|
||||||
{
|
{
|
||||||
@ -2112,7 +2157,8 @@ static bool logfile_init(
|
|||||||
logfile->lf_full_file_name =
|
logfile->lf_full_file_name =
|
||||||
form_full_file_name(strparts, logfile->lf_name_seqno, 2);
|
form_full_file_name(strparts, logfile->lf_name_seqno, 2);
|
||||||
|
|
||||||
if (store_shmem) {
|
if (store_shmem)
|
||||||
|
{
|
||||||
strparts[0].sp_string = logfile->lf_linkpath;
|
strparts[0].sp_string = logfile->lf_linkpath;
|
||||||
/**
|
/**
|
||||||
* Create name for link file
|
* Create name for link file
|
||||||
@ -2121,16 +2167,6 @@ static bool logfile_init(
|
|||||||
form_full_file_name(strparts,
|
form_full_file_name(strparts,
|
||||||
logfile->lf_name_seqno,
|
logfile->lf_name_seqno,
|
||||||
2);
|
2);
|
||||||
fprintf(stderr, "%s\t: %s->%s\n",
|
|
||||||
STRLOGNAME(logfile_id),
|
|
||||||
logfile->lf_full_link_name,
|
|
||||||
logfile->lf_full_file_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s\t: %s\n",
|
|
||||||
STRLOGNAME(logfile_id),
|
|
||||||
logfile->lf_full_file_name);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* At least one of the files couldn't be created. Increase
|
* At least one of the files couldn't be created. Increase
|
||||||
@ -2147,9 +2183,11 @@ static bool logfile_init(
|
|||||||
* If file exists but is different type, create fails and
|
* If file exists but is different type, create fails and
|
||||||
* new, increased sequence number is added to file name.
|
* new, increased sequence number is added to file name.
|
||||||
*/
|
*/
|
||||||
if (file_exists_and_is_writable(logfile->lf_full_file_name,
|
if (check_file_and_path(
|
||||||
|
logfile->lf_full_file_name,
|
||||||
&writable))
|
&writable))
|
||||||
{
|
{
|
||||||
|
/** Found similarly named file which isn't writable */
|
||||||
if (!writable ||
|
if (!writable ||
|
||||||
file_is_symlink(logfile->lf_full_file_name))
|
file_is_symlink(logfile->lf_full_file_name))
|
||||||
{
|
{
|
||||||
@ -2157,22 +2195,45 @@ static bool logfile_init(
|
|||||||
goto file_create_fail;
|
goto file_create_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Opening the file failed for some other reason than
|
||||||
|
* existing non-writable file. Shut down.
|
||||||
|
*/
|
||||||
|
if (!writable)
|
||||||
|
{
|
||||||
|
succp = false;
|
||||||
|
goto return_with_succp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (store_shmem)
|
if (store_shmem)
|
||||||
{
|
{
|
||||||
writable = false;
|
if (check_file_and_path(
|
||||||
|
logfile->lf_full_file_name,
|
||||||
if (file_exists_and_is_writable(
|
|
||||||
logfile->lf_full_link_name,
|
|
||||||
&writable))
|
&writable))
|
||||||
{
|
{
|
||||||
|
/** Found similarly named file which isn't writable */
|
||||||
if (!writable ||
|
if (!writable ||
|
||||||
!file_is_symlink(logfile->lf_full_link_name))
|
file_is_symlink(logfile->lf_full_file_name))
|
||||||
{
|
{
|
||||||
nameconflicts = true;
|
nameconflicts = true;
|
||||||
goto file_create_fail;
|
goto file_create_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Opening the file failed for some other reason than
|
||||||
|
* existing non-writable file. Shut down.
|
||||||
|
*/
|
||||||
|
if (!writable)
|
||||||
|
{
|
||||||
|
succp = false;
|
||||||
|
goto return_with_succp;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
file_create_fail:
|
file_create_fail:
|
||||||
if (namecreatefail || nameconflicts)
|
if (namecreatefail || nameconflicts)
|
||||||
@ -2189,7 +2250,6 @@ file_create_fail:
|
|||||||
free(logfile->lf_full_link_name);
|
free(logfile->lf_full_link_name);
|
||||||
logfile->lf_full_link_name = NULL;
|
logfile->lf_full_link_name = NULL;
|
||||||
}
|
}
|
||||||
goto return_with_succp;
|
|
||||||
}
|
}
|
||||||
} while (namecreatefail || nameconflicts);
|
} while (namecreatefail || nameconflicts);
|
||||||
/**
|
/**
|
||||||
@ -2203,11 +2263,24 @@ file_create_fail:
|
|||||||
MAXNBLOCKBUFS) == NULL)
|
MAXNBLOCKBUFS) == NULL)
|
||||||
{
|
{
|
||||||
ss_dfprintf(stderr,
|
ss_dfprintf(stderr,
|
||||||
"Initializing logfile blockbuf list "
|
"*\n* Error : Initializing buffers for log files "
|
||||||
"failed\n");
|
"failed.");
|
||||||
logfile_free_memory(logfile);
|
logfile_free_memory(logfile);
|
||||||
goto return_with_succp;
|
goto return_with_succp;
|
||||||
}
|
}
|
||||||
|
if (store_shmem)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\t: %s->%s\n",
|
||||||
|
STRLOGNAME(logfile_id),
|
||||||
|
logfile->lf_full_link_name,
|
||||||
|
logfile->lf_full_file_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\t: %s\n",
|
||||||
|
STRLOGNAME(logfile_id),
|
||||||
|
logfile->lf_full_file_name);
|
||||||
|
}
|
||||||
succp = true;
|
succp = true;
|
||||||
logfile->lf_state = RUN;
|
logfile->lf_state = RUN;
|
||||||
CHK_LOGFILE(logfile);
|
CHK_LOGFILE(logfile);
|
||||||
@ -2247,10 +2320,16 @@ static void logfile_done(
|
|||||||
case RUN:
|
case RUN:
|
||||||
CHK_LOGFILE(lf);
|
CHK_LOGFILE(lf);
|
||||||
ss_dassert(lf->lf_npending_writes == 0);
|
ss_dassert(lf->lf_npending_writes == 0);
|
||||||
|
/** fallthrough */
|
||||||
case INIT:
|
case INIT:
|
||||||
|
/** Test if list is initialized before freeing it */
|
||||||
|
if (lf->lf_blockbuf_list.mlist_versno != 0)
|
||||||
|
{
|
||||||
mlist_done(&lf->lf_blockbuf_list);
|
mlist_done(&lf->lf_blockbuf_list);
|
||||||
|
}
|
||||||
logfile_free_memory(lf);
|
logfile_free_memory(lf);
|
||||||
lf->lf_state = DONE;
|
lf->lf_state = DONE;
|
||||||
|
/** fallthrough */
|
||||||
case DONE:
|
case DONE:
|
||||||
case UNINIT:
|
case UNINIT:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -73,7 +73,9 @@
|
|||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
|
||||||
/** for procname */
|
/** for procname */
|
||||||
#define _GNU_SOURCE
|
#if !defined(_GNU_SOURCE)
|
||||||
|
# define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char *program_invocation_name;
|
extern char *program_invocation_name;
|
||||||
extern char *program_invocation_short_name;
|
extern char *program_invocation_short_name;
|
||||||
@ -174,6 +176,9 @@ static bool resolve_maxscale_conf_fname(
|
|||||||
char* cnf_file_arg);
|
char* cnf_file_arg);
|
||||||
static bool resolve_maxscale_homedir(
|
static bool resolve_maxscale_homedir(
|
||||||
char** p_home_dir);
|
char** p_home_dir);
|
||||||
|
|
||||||
|
static char* check_dir_access(char* dirname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for SIGHUP signal. Reload the configuration for the
|
* Handler for SIGHUP signal. Reload the configuration for the
|
||||||
* gateway.
|
* gateway.
|
||||||
@ -593,64 +598,44 @@ static bool resolve_maxscale_homedir(
|
|||||||
if (*p_home_dir != NULL)
|
if (*p_home_dir != NULL)
|
||||||
{
|
{
|
||||||
log_context = strdup("Current working directory");
|
log_context = strdup("Current working directory");
|
||||||
goto check_home_dir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_home_dir:
|
check_home_dir:
|
||||||
|
|
||||||
if (*p_home_dir != NULL)
|
if (*p_home_dir != NULL)
|
||||||
{
|
{
|
||||||
if (!file_is_readable(*p_home_dir))
|
char* errstr;
|
||||||
|
|
||||||
|
errstr = check_dir_access(*p_home_dir);
|
||||||
|
|
||||||
|
if (errstr != NULL)
|
||||||
{
|
{
|
||||||
char* tailstr = "MaxScale doesn't have read permission "
|
|
||||||
"to MAXSCALE_HOME.";
|
|
||||||
char* logstr = (char*)malloc(strlen(log_context)+
|
char* logstr = (char*)malloc(strlen(log_context)+
|
||||||
1+
|
1+
|
||||||
strlen(tailstr)+
|
strlen(errstr)+
|
||||||
1);
|
1);
|
||||||
|
|
||||||
snprintf(logstr,
|
snprintf(logstr,
|
||||||
strlen(log_context)+
|
strlen(log_context)+
|
||||||
1+
|
1+
|
||||||
strlen(tailstr)+1,
|
strlen(errstr)+1,
|
||||||
"%s:%s",
|
"%s: %s",
|
||||||
log_context,
|
log_context,
|
||||||
tailstr);
|
errstr);
|
||||||
print_log_n_stderr(true, true, logstr, logstr, 0);
|
|
||||||
free(logstr);
|
|
||||||
goto return_succp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_is_writable(*p_home_dir))
|
|
||||||
{
|
|
||||||
char* tailstr = "MaxScale doesn't have write permission "
|
|
||||||
"to MAXSCALE_HOME. Exiting.";
|
|
||||||
char* logstr = (char*)malloc(strlen(log_context)+
|
|
||||||
1+
|
|
||||||
strlen(tailstr)+
|
|
||||||
1);
|
|
||||||
snprintf(logstr,
|
|
||||||
strlen(log_context)+
|
|
||||||
1+
|
|
||||||
strlen(tailstr)+1,
|
|
||||||
"%s:%s",
|
|
||||||
log_context,
|
|
||||||
tailstr);
|
|
||||||
print_log_n_stderr(true, true, logstr, logstr, 0);
|
print_log_n_stderr(true, true, logstr, logstr, 0);
|
||||||
free(logstr);
|
|
||||||
goto return_succp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!daemon_mode)
|
free(errstr);
|
||||||
|
free(logstr);
|
||||||
|
}
|
||||||
|
else if (!daemon_mode)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Using %s as MAXSCALE_HOME = %s\n",
|
"Using %s as MAXSCALE_HOME = %s\n",
|
||||||
log_context,
|
log_context,
|
||||||
tmp);
|
tmp);
|
||||||
}
|
}
|
||||||
succp = true;
|
|
||||||
goto return_succp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return_succp:
|
|
||||||
free (tmp);
|
free (tmp);
|
||||||
|
|
||||||
if (log_context != NULL)
|
if (log_context != NULL)
|
||||||
@ -668,6 +653,42 @@ return_succp:
|
|||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check read and write accessibility to a directory.
|
||||||
|
* @param dirname directory to be checked
|
||||||
|
*
|
||||||
|
* @return NULL if directory can be read and written, an error message if either
|
||||||
|
* read or write is not permitted.
|
||||||
|
*/
|
||||||
|
static char* check_dir_access(
|
||||||
|
char* dirname)
|
||||||
|
{
|
||||||
|
char* errstr = NULL;
|
||||||
|
|
||||||
|
if (dirname == NULL)
|
||||||
|
{
|
||||||
|
errstr = strdup("Directory argument is NULL");
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_is_readable(dirname))
|
||||||
|
{
|
||||||
|
errstr = strdup("MaxScale doesn't have read permission "
|
||||||
|
"to MAXSCALE_HOME.");
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_is_writable(dirname))
|
||||||
|
{
|
||||||
|
errstr = strdup("MaxScale doesn't have write permission "
|
||||||
|
"to MAXSCALE_HOME. Exiting.");
|
||||||
|
goto retblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
retblock:
|
||||||
|
return errstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @node Provides error printing for non-formatted error strings.
|
* @node Provides error printing for non-formatted error strings.
|
||||||
@ -1378,6 +1399,44 @@ int main(int argc, char **argv)
|
|||||||
sprintf(mysql_home, "%s/mysql", home_dir);
|
sprintf(mysql_home, "%s/mysql", home_dir);
|
||||||
setenv("MYSQL_HOME", mysql_home, 1);
|
setenv("MYSQL_HOME", mysql_home, 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char* log_context = strdup("Home directory command-line argument");
|
||||||
|
char* errstr;
|
||||||
|
|
||||||
|
errstr = check_dir_access(home_dir);
|
||||||
|
|
||||||
|
if (errstr != NULL)
|
||||||
|
{
|
||||||
|
char* logstr = (char*)malloc(strlen(log_context)+
|
||||||
|
1+
|
||||||
|
strlen(errstr)+
|
||||||
|
1);
|
||||||
|
|
||||||
|
snprintf(logstr,
|
||||||
|
strlen(log_context)+
|
||||||
|
1+
|
||||||
|
strlen(errstr)+1,
|
||||||
|
"%s: %s",
|
||||||
|
log_context,
|
||||||
|
errstr);
|
||||||
|
|
||||||
|
print_log_n_stderr(true, true, logstr, logstr, 0);
|
||||||
|
|
||||||
|
free(errstr);
|
||||||
|
free(logstr);
|
||||||
|
rc = MAXSCALE_HOMELESS;
|
||||||
|
goto return_main;
|
||||||
|
}
|
||||||
|
else if (!daemon_mode)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Using %s as MAXSCALE_HOME = %s\n",
|
||||||
|
log_context,
|
||||||
|
home_dir);
|
||||||
|
}
|
||||||
|
free(log_context);
|
||||||
|
}
|
||||||
|
|
||||||
/*<
|
/*<
|
||||||
* Init Log Manager for MaxScale.
|
* Init Log Manager for MaxScale.
|
||||||
@ -1389,6 +1448,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *argv[8];
|
char *argv[8];
|
||||||
|
bool succp;
|
||||||
|
|
||||||
sprintf(buf, "%s/log", home_dir);
|
sprintf(buf, "%s/log", home_dir);
|
||||||
mkdir(buf, 0777);
|
mkdir(buf, 0777);
|
||||||
@ -1401,7 +1461,7 @@ int main(int argc, char **argv)
|
|||||||
argv[4] = "LOGFILE_MESSAGE,LOGFILE_ERROR"
|
argv[4] = "LOGFILE_MESSAGE,LOGFILE_ERROR"
|
||||||
"LOGFILE_DEBUG,LOGFILE_TRACE";
|
"LOGFILE_DEBUG,LOGFILE_TRACE";
|
||||||
argv[5] = NULL;
|
argv[5] = NULL;
|
||||||
skygw_logmanager_init(5, argv);
|
succp = skygw_logmanager_init(5, argv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1410,7 +1470,13 @@ int main(int argc, char **argv)
|
|||||||
argv[5] = "-l"; /*< write to syslog */
|
argv[5] = "-l"; /*< write to syslog */
|
||||||
argv[6] = "LOGFILE_MESSAGE,LOGFILE_ERROR"; /*< ..these logs to syslog */
|
argv[6] = "LOGFILE_MESSAGE,LOGFILE_ERROR"; /*< ..these logs to syslog */
|
||||||
argv[7] = NULL;
|
argv[7] = NULL;
|
||||||
skygw_logmanager_init(7, argv);
|
succp = skygw_logmanager_init(7, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!succp)
|
||||||
|
{
|
||||||
|
rc = MAXSCALE_BADCONFIG;
|
||||||
|
goto return_main;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -320,6 +320,7 @@ mlist_t* mlist_init(
|
|||||||
list->mlist_nodecount_max = maxnodes;
|
list->mlist_nodecount_max = maxnodes;
|
||||||
/** Set data deletion callback fun */
|
/** Set data deletion callback fun */
|
||||||
list->mlist_datadel = datadel;
|
list->mlist_datadel = datadel;
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
list->mlist_name = name;
|
list->mlist_name = name;
|
||||||
}
|
}
|
||||||
@ -345,6 +346,7 @@ mlist_t* mlist_init(
|
|||||||
CHK_MLIST_CURSOR(c);
|
CHK_MLIST_CURSOR(c);
|
||||||
*cursor = c;
|
*cursor = c;
|
||||||
}
|
}
|
||||||
|
list->mlist_versno = 2; /*< vresno != 0 means that list is initialized */
|
||||||
CHK_MLIST(list);
|
CHK_MLIST(list);
|
||||||
|
|
||||||
return_list:
|
return_list:
|
||||||
|
|||||||
@ -52,9 +52,7 @@ typedef struct mlist_st {
|
|||||||
bool mlist_deleted;
|
bool mlist_deleted;
|
||||||
size_t mlist_nodecount;
|
size_t mlist_nodecount;
|
||||||
size_t mlist_nodecount_max; /**< size limit. 0 == no limit */
|
size_t mlist_nodecount_max; /**< size limit. 0 == no limit */
|
||||||
#if 1
|
|
||||||
size_t mlist_versno;
|
size_t mlist_versno;
|
||||||
#endif
|
|
||||||
bool mlist_flat;
|
bool mlist_flat;
|
||||||
mlist_node_t* mlist_first;
|
mlist_node_t* mlist_first;
|
||||||
mlist_node_t* mlist_last;
|
mlist_node_t* mlist_last;
|
||||||
|
|||||||
Reference in New Issue
Block a user