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:
@ -979,7 +979,7 @@ parsing_info_t* parsing_info_init(
|
||||
LOGFILE_ERROR,
|
||||
"Error : call to mysql_real_connect failed due %d, %s.",
|
||||
mysql_errno(mysql),
|
||||
mysql_error(mysql))));
|
||||
mysql_error(mysql))));
|
||||
|
||||
goto retblock;
|
||||
}
|
||||
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1339,11 +1339,16 @@ 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)
|
||||
|
||||
if (n_services == 0)
|
||||
{
|
||||
char* logerr = "Failed to start any MaxScale services. Exiting.";
|
||||
print_log_n_stderr(true, !daemon_mode, logerr, logerr, 0);
|
||||
@ -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,
|
||||
|
@ -252,9 +252,11 @@ 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)
|
||||
{
|
||||
#if BLOCKINGPOLL
|
||||
@ -495,6 +497,8 @@ poll_waitevents(void *arg)
|
||||
return;
|
||||
}
|
||||
} /*< while(1) */
|
||||
/** Release mysql thread context */
|
||||
mysql_thread_end();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1947,6 +1947,7 @@ char* replace_literal(
|
||||
|
||||
regfree(&re);
|
||||
free(haystack);
|
||||
free(search_re);
|
||||
retblock:
|
||||
return newstr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user