Merge branch 'develop' into MAX-324

Conflicts:
	utils/skygw_utils.cc
This commit is contained in:
Markus Makela
2015-03-06 17:07:39 +02:00
8 changed files with 68 additions and 6 deletions

View File

@ -52,6 +52,8 @@ static int prevval;
static simple_mutex_t msg_mutex; static simple_mutex_t msg_mutex;
#endif #endif
static int highprec = 0; static int highprec = 0;
static int do_syslog = 1;
/** /**
* Variable holding the enabled logfiles information. * Variable holding the enabled logfiles information.
* Used from log users to check enabled logs prior calling * Used from log users to check enabled logs prior calling
@ -392,7 +394,13 @@ static bool logmanager_init_nomutex(
fw = &lm->lm_filewriter; fw = &lm->lm_filewriter;
fn->fn_state = UNINIT; fn->fn_state = UNINIT;
fw->fwr_state = UNINIT; fw->fwr_state = UNINIT;
if(!do_syslog)
{
free(syslog_id_str);
syslog_id_str = NULL;
}
/** 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))
{ {
@ -1703,11 +1711,14 @@ static bool fnames_conf_init(
case 'l': case 'l':
/** record list of log file ids for syslogged */ /** record list of log file ids for syslogged */
if(do_syslog)
{
if (syslog_id_str != NULL) if (syslog_id_str != NULL)
{ {
free (syslog_id_str); free (syslog_id_str);
} }
syslog_id_str = optarg; syslog_id_str = optarg;
}
break; break;
case 'm': case 'm':
@ -1720,6 +1731,7 @@ static bool fnames_conf_init(
case 's': case 's':
/** record list of log file ids for later use */ /** record list of log file ids for later use */
if(do_syslog)
shmem_id_str = optarg; shmem_id_str = optarg;
break; break;
case 'h': case 'h':
@ -3083,7 +3095,21 @@ void skygw_log_sync_all(void)
skygw_message_wait(lm->lm_clientmes); skygw_message_wait(lm->lm_clientmes);
} }
/**
* Toggle high precision logging
* @param val 0 for disabled, 1 for enabled
*/
void skygw_set_highp(int val) void skygw_set_highp(int val)
{ {
highprec = val; highprec = val;
}
/**
* Toggle syslog logging
* @param val 0 for disabled, 1 for enabled
*/
void logmanager_enable_syslog(int val)
{
do_syslog = val;
} }

View File

@ -120,6 +120,7 @@ int skygw_log_enable(logfile_id_t id);
int skygw_log_disable(logfile_id_t id); int skygw_log_disable(logfile_id_t id);
void skygw_log_sync_all(void); void skygw_log_sync_all(void);
void skygw_set_highp(int); void skygw_set_highp(int);
void logmanager_enable_syslog(int);
EXTERN_C_BLOCK_END EXTERN_C_BLOCK_END
const char* get_trace_prefix_default(void); const char* get_trace_prefix_default(void);

View File

@ -150,6 +150,7 @@ static struct option long_options[] = {
{"config", required_argument, 0, 'f'}, {"config", required_argument, 0, 'f'},
{"nodaemon", no_argument, 0, 'd'}, {"nodaemon", no_argument, 0, 'd'},
{"log", required_argument, 0, 'l'}, {"log", required_argument, 0, 'l'},
{"syslog", required_argument, 0, 's'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'}, {"help", no_argument, 0, '?'},
{0, 0, 0, 0} {0, 0, 0, 0}
@ -995,6 +996,8 @@ static void usage(void)
" (default: $MAXSCALE_HOME/etc/MaxScale.cnf)\n" " (default: $MAXSCALE_HOME/etc/MaxScale.cnf)\n"
" -l|--log=... log to file or shared memory\n" " -l|--log=... log to file or shared memory\n"
" -lfile or -lshm - defaults to shared memory\n" " -lfile or -lshm - defaults to shared memory\n"
" -s|--syslog= log messages to syslog"
" true or false - defaults to true"
" -v|--version print version info and exit\n" " -v|--version print version info and exit\n"
" -?|--help show this help\n" " -?|--help show this help\n"
, progname); , progname);
@ -1057,6 +1060,7 @@ int main(int argc, char **argv)
void* log_flush_thr = NULL; void* log_flush_thr = NULL;
int option_index; int option_index;
int logtofile = 0; /* Use shared memory or file */ int logtofile = 0; /* Use shared memory or file */
int syslog_enabled = 1; /** Log to syslog */
ssize_t log_flush_timeout_ms = 0; ssize_t log_flush_timeout_ms = 0;
sigset_t sigset; sigset_t sigset;
sigset_t sigpipe_mask; sigset_t sigpipe_mask;
@ -1096,7 +1100,7 @@ int main(int argc, char **argv)
goto return_main; goto return_main;
} }
} }
while ((opt = getopt_long(argc, argv, "dc:f:l:v?", while ((opt = getopt_long(argc, argv, "dc:f:l:vs:?",
long_options, &option_index)) != -1) long_options, &option_index)) != -1)
{ {
bool succp = true; bool succp = true;
@ -1201,7 +1205,17 @@ int main(int argc, char **argv)
succp = false; succp = false;
} }
break; break;
case 's':
if(strstr(optarg,"="))
{
strtok(optarg,"= ");
syslog_enabled = config_truth_value(strtok(NULL,"= "));
}
else
{
syslog_enabled = config_truth_value(optarg);
}
break;
case '?': case '?':
usage(); usage();
rc = EXIT_SUCCESS; rc = EXIT_SUCCESS;
@ -1563,6 +1577,8 @@ int main(int argc, char **argv)
argv[0] = "MaxScale"; argv[0] = "MaxScale";
argv[1] = "-j"; argv[1] = "-j";
argv[2] = buf; argv[2] = buf;
logmanager_enable_syslog(syslog_enabled);
if (logtofile) if (logtofile)
{ {

View File

@ -116,9 +116,20 @@ HKTASK *task, *ptr;
ptr = ptr->next; ptr = ptr->next;
} }
if (ptr) if (ptr)
{
if (strcmp(ptr->name, name) == 0)
{
spinlock_release(&tasklock);
free(task->name);
free(task);
return 0;
}
ptr->next = task; ptr->next = task;
}
else else
{
tasks = task; tasks = task;
}
spinlock_release(&tasklock); spinlock_release(&tasklock);
return task->nextdue; return task->nextdue;

View File

@ -290,6 +290,7 @@ struct router_client_session {
int rses_capabilities; /*< input type, for example */ int rses_capabilities; /*< input type, for example */
bool rses_autocommit_enabled; bool rses_autocommit_enabled;
bool rses_transaction_active; bool rses_transaction_active;
DCB* client_dcb;
#if defined(PREP_STMT_CACHING) #if defined(PREP_STMT_CACHING)
HASHTABLE* rses_prep_stmt[2]; HASHTABLE* rses_prep_stmt[2];
#endif #endif

View File

@ -790,6 +790,7 @@ static void* newSession(
#endif #endif
client_rses->router = router; client_rses->router = router;
client_rses->client_dcb = session->client;
/** /**
* If service config has been changed, reload config from service to * If service config has been changed, reload config from service to
* router instance first. * router instance first.
@ -4353,8 +4354,10 @@ static bool route_session_write(
LOGFILE_TRACE, LOGFILE_TRACE,
"Router session exceeded session command history limit. " "Router session exceeded session command history limit. "
"Closing router session. <"))); "Closing router session. <")));
router_cli_ses->rses_closed = true; gwbuf_free(querybuf);
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
router_cli_ses->client_dcb->func.hangup(router_cli_ses->client_dcb);
goto return_succp; goto return_succp;
} }

View File

@ -1,4 +1,4 @@
execute_process(COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null") execute_process(COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null 2> /dev/null > /dev/null")
execute_process(COMMAND make test RESULT_VARIABLE RVAL) execute_process(COMMAND make test RESULT_VARIABLE RVAL)
execute_process(COMMAND killall maxscale) execute_process(COMMAND killall maxscale)
if(NOT RVAL EQUAL 0) if(NOT RVAL EQUAL 0)

View File

@ -145,12 +145,16 @@ int atomic_add(
int *variable, int *variable,
int value) int value)
{ {
#ifdef __GNUC__
return (int) __sync_fetch_and_add (variable, value);
#else
asm volatile( asm volatile(
"lock; xaddl %%eax, %2;" "lock; xaddl %%eax, %2;"
:"=a" (value) :"=a" (value)
: "a" (value), "m" (*variable) : "a" (value), "m" (*variable)
: "memory" ); : "memory" );
return value; return value;
#endif
} }
@ -2171,4 +2175,4 @@ strip_escape_chars (char* val)
cur++; cur++;
} }
return true; return true;
} }