Merge branch 'develop' into release-1.1.1

Conflicts:
	server/modules/routing/schemarouter/schemarouter.c
This commit is contained in:
Markus Makela
2015-05-06 12:24:09 +03:00
13 changed files with 218 additions and 172 deletions

View File

@ -54,7 +54,7 @@ static simple_mutex_t msg_mutex;
static int highprec = 0;
static int do_syslog = 1;
static int do_maxscalelog = 1;
static int use_stdout = 0;
/**
* Variable holding the enabled logfiles information.
* Used from log users to check enabled logs prior calling
@ -1350,12 +1350,14 @@ static bool logfile_set_enabled(
}
lf = &lm->lm_logfile[id];
CHK_LOGFILE(lf);
if (val) {
logstr = strdup("---\tLogging to file is enabled\t--");
} else {
logstr = strdup("---\tLogging to file is disabled\t--");
}
if(use_stdout == 0)
{
if (val) {
logstr = strdup("---\tLogging to file is enabled\t--");
} else {
logstr = strdup("---\tLogging to file is disabled\t--");
}
oldval = lf->lf_enabled;
lf->lf_enabled = val;
err = logmanager_write_log(id,
@ -1367,7 +1369,7 @@ static bool logfile_set_enabled(
logstr,
notused);
free(logstr);
}
if (err != 0) {
lf->lf_enabled = oldval;
fprintf(stderr,
@ -1464,7 +1466,7 @@ int skygw_log_write(
* Find out the length of log string (to be formatted str).
*/
va_start(valist, str);
len = vsnprintf(NULL, 0, str, valist);
len = vsnprintf(NULL, 0, str, valist);
va_end(valist);
/**
* Add one for line feed.
@ -1714,9 +1716,12 @@ static bool fnames_conf_init(
fn->fn_chk_tail = CHK_NUM_FNAMES;
#endif
optind = 1; /**<! reset getopt index */
while ((opt = getopt(argc, argv, "+a:b:c:d:e:f:g:h:i:j:l:m:s:")) != -1)
while ((opt = getopt(argc, argv, "+a:b:c:d:e:f:g:h:i:j:l:m:s:o")) != -1)
{
switch (opt) {
case 'o':
use_stdout = 1;
break;
case 'a':
fn->fn_debug_prefix = strndup(optarg, MAX_PREFIXLEN);
break;
@ -2172,8 +2177,14 @@ static bool logfile_open_file(
bool succp;
char* start_msg_str;
int err;
if (lf->lf_store_shmem)
if(use_stdout)
{
fw->fwr_file[lf->lf_id] = skygw_file_alloc (
lf->lf_full_file_name);
fw->fwr_file[lf->lf_id]->sf_file = stdout;
}
else if (lf->lf_store_shmem)
{
/** Create symlink pointing to log file */
fw->fwr_file[lf->lf_id] = skygw_file_init(
@ -2196,32 +2207,35 @@ static bool logfile_open_file(
succp = false;
goto return_succp;
}
if (lf->lf_enabled)
{
if(use_stdout == 0)
{
if (lf->lf_enabled)
{
start_msg_str = strdup("---\tLogging is enabled.\n");
}
else
{
}
else
{
start_msg_str = strdup("---\tLogging is disabled.\n");
}
err = skygw_file_write(fw->fwr_file[lf->lf_id],
(void *)start_msg_str,
strlen(start_msg_str),
true);
if (err != 0)
{
}
err = skygw_file_write(fw->fwr_file[lf->lf_id],
(void *)start_msg_str,
strlen(start_msg_str),
true);
if (err != 0)
{
fprintf(stderr,
"Error : writing to file %s failed due to %d, %s. "
"Error : writing to file %s failed due to %d, %s. "
"Exiting MaxScale.\n",
lf->lf_full_file_name,
err,
strerror(err));
lf->lf_full_file_name,
err,
strerror(err));
succp = false;
goto return_succp;
}
free(start_msg_str);
}
free(start_msg_str);
}
succp = true;
return_succp:
@ -2746,7 +2760,10 @@ static void filewriter_done(
for (i=LOGFILE_FIRST; i<=LOGFILE_LAST; i++)
{
id = (logfile_id_t)i;
skygw_file_close(fw->fwr_file[id], true);
if(use_stdout)
skygw_file_free(fw->fwr_file[id]);
else
skygw_file_close(fw->fwr_file[id], true);
}
fw->fwr_state = DONE;
case DONE:
@ -2878,6 +2895,9 @@ static void* thr_filewriter_fun(
}
else if ((succp = logfile_open_file(fwr, lf)))
{
if(use_stdout)
skygw_file_free (file);
else
skygw_file_close(file, false); /*< close old file */
}