Fix to bug #510, http://bugs.skysql.com/show_bug.cgi?id=510, made every MaxScale thread to call mysql_thread_init() before entering poll_waitevents. Also main thread does this before starting services. Removed all calls to mysql_thread_init() and to mysql_thread_end() from elsewhere than from poll.c:poll_waitevents and from gateway.c:main
skygw_utils.cc: replace_literal: fixed memory leak
This commit is contained in:
@ -996,7 +996,6 @@ parsing_info_t* parsing_info_init(
|
|||||||
if (pi == NULL)
|
if (pi == NULL)
|
||||||
{
|
{
|
||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
mysql_thread_end();
|
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
|
@ -187,14 +187,6 @@ getUsers(SERVICE *service, struct users *users)
|
|||||||
if (service_user == NULL || service_passwd == NULL)
|
if (service_user == NULL || service_passwd == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/** multi-thread environment requires that thread init succeeds. */
|
|
||||||
if (mysql_thread_init()) {
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"Error : mysql_thread_init failed.")));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
con = mysql_init(NULL);
|
con = mysql_init(NULL);
|
||||||
|
|
||||||
if (con == NULL) {
|
if (con == NULL) {
|
||||||
@ -391,7 +383,6 @@ getUsers(SERVICE *service, struct users *users)
|
|||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
mysql_close(con);
|
mysql_close(con);
|
||||||
mysql_thread_end();
|
|
||||||
|
|
||||||
return total_users;
|
return total_users;
|
||||||
}
|
}
|
||||||
|
@ -1339,10 +1339,15 @@ int main(int argc, char **argv)
|
|||||||
/* Init MaxScale poll system */
|
/* Init MaxScale poll system */
|
||||||
poll_init();
|
poll_init();
|
||||||
|
|
||||||
/*<
|
/**
|
||||||
* Start the services that were created above
|
* Init mysql thread context for main thread as well. Needed when users
|
||||||
|
* are queried from backends.
|
||||||
*/
|
*/
|
||||||
|
mysql_thread_init();
|
||||||
|
|
||||||
|
/** Start the services that were created above */
|
||||||
n_services = serviceStartAll();
|
n_services = serviceStartAll();
|
||||||
|
|
||||||
if (n_services == 0)
|
if (n_services == 0)
|
||||||
{
|
{
|
||||||
char* logerr = "Failed to start any MaxScale services. Exiting.";
|
char* logerr = "Failed to start any MaxScale services. Exiting.";
|
||||||
@ -1396,9 +1401,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/*< Stop all the monitors */
|
/*< Stop all the monitors */
|
||||||
monitorStopAll();
|
monitorStopAll();
|
||||||
|
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"MaxScale is shutting down.")));
|
"MaxScale is shutting down.")));
|
||||||
|
/** Release mysql thread context*/
|
||||||
|
mysql_thread_end();
|
||||||
|
|
||||||
datadir_cleanup();
|
datadir_cleanup();
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
|
@ -252,8 +252,10 @@ poll_waitevents(void *arg)
|
|||||||
static bool process_zombies_only = false; /*< flag for all threads */
|
static bool process_zombies_only = false; /*< flag for all threads */
|
||||||
DCB *zombies = NULL;
|
DCB *zombies = NULL;
|
||||||
|
|
||||||
/* Add this thread to the bitmask of running polling threads */
|
/** Add this thread to the bitmask of running polling threads */
|
||||||
bitmask_set(&poll_mask, thread_id);
|
bitmask_set(&poll_mask, thread_id);
|
||||||
|
/** Init mysql thread context for use with a mysql handle and a parser */
|
||||||
|
mysql_thread_init();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -495,6 +497,8 @@ poll_waitevents(void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} /*< while(1) */
|
} /*< while(1) */
|
||||||
|
/** Release mysql thread context */
|
||||||
|
mysql_thread_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1947,6 +1947,7 @@ char* replace_literal(
|
|||||||
|
|
||||||
regfree(&re);
|
regfree(&re);
|
||||||
free(haystack);
|
free(haystack);
|
||||||
|
free(search_re);
|
||||||
retblock:
|
retblock:
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user