Fix auxiliary thread problems related to multiple processes

This commit is contained in:
wangbin579 2018-08-16 10:53:14 +08:00
parent 25e75fc42c
commit cb755e414f
2 changed files with 8 additions and 6 deletions

View File

@ -6,6 +6,8 @@
#include <net/if.h>
#include <sys/ioctl.h>
#include "chassis-sql-log.h"
#include "cetus-monitor.h"
#include "network-mysqld.h"
#include "cetus-channel.h"
#include "cetus-process.h"
@ -534,6 +536,10 @@ cetus_worker_process_cycle(cetus_cycle_t *cycle, void *data)
incremental_guid_init(&(cycle->guid_state));
#endif
cetus_monitor_start_thread(cycle->priv->monitor, cycle);
cetus_sql_log_start_thread_once(cycle->sql_mgr);
for ( ;; ) {
if (cetus_exiting) {
@ -647,6 +653,8 @@ cetus_worker_process_exit(cetus_cycle_t *cycle)
{
unsigned int i;
cetus_monitor_stop_thread(cycle->priv->monitor);
g_message("%s: exit", G_STRLOC);
exit(0);

View File

@ -634,7 +634,6 @@ init_parameters(struct chassis_frontend_t *frontend, chassis *srv)
srv->default_db = DUP_STRING(frontend->default_db, NULL);
srv->ifname = DUP_STRING(frontend->ifname, "eth0");
frontend->worker_processes = 1;
if (frontend->worker_processes < 1) {
srv->worker_processes = 4;
} else if (frontend->worker_processes > MAX_WORK_PROCESSES) {
@ -1220,17 +1219,12 @@ main_cmdline(int argc, char **argv)
}
}
cetus_monitor_start_thread(srv->priv->monitor, srv);
cetus_sql_log_start_thread_once(srv->sql_mgr);
if (chassis_mainloop(srv)) {
/* looks like we failed */
g_critical("%s: Failure from chassis_mainloop. Shutting down.", G_STRLOC);
GOTO_EXIT(EXIT_FAILURE);
}
cetus_monitor_stop_thread(srv->priv->monitor);
exit_nicely:
/* necessary to set the shutdown flag, because the monitor will continue
* to schedule timers otherwise, causing an infinite loop in cleanup