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:
VilhoRaatikka
2014-09-01 19:37:31 +03:00
parent 3c1abf4b64
commit 0fed5c2c5b
5 changed files with 21 additions and 17 deletions

View File

@ -996,7 +996,6 @@ parsing_info_t* parsing_info_init(
if (pi == NULL)
{
mysql_close(mysql);
mysql_thread_end();
goto retblock;
}
#if defined(SS_DEBUG)

View File

@ -187,14 +187,6 @@ getUsers(SERVICE *service, struct users *users)
if (service_user == NULL || service_passwd == NULL)
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);
if (con == NULL) {
@ -391,7 +383,6 @@ getUsers(SERVICE *service, struct users *users)
mysql_free_result(result);
mysql_close(con);
mysql_thread_end();
return total_users;
}

View File

@ -1339,10 +1339,15 @@ int main(int argc, char **argv)
/* Init MaxScale poll system */
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();
if (n_services == 0)
{
char* logerr = "Failed to start any MaxScale services. Exiting.";
@ -1396,9 +1401,13 @@ int main(int argc, char **argv)
/*< Stop all the monitors */
monitorStopAll();
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"MaxScale is shutting down.")));
/** Release mysql thread context*/
mysql_thread_end();
datadir_cleanup();
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,

View File

@ -252,8 +252,10 @@ poll_waitevents(void *arg)
static bool process_zombies_only = false; /*< flag for all threads */
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);
/** Init mysql thread context for use with a mysql handle and a parser */
mysql_thread_init();
while (1)
{
@ -495,6 +497,8 @@ poll_waitevents(void *arg)
return;
}
} /*< while(1) */
/** Release mysql thread context */
mysql_thread_end();
}
/**

View File

@ -1947,6 +1947,7 @@ char* replace_literal(
regfree(&re);
free(haystack);
free(search_re);
retblock:
return newstr;
}