Commit 84b7a8e6 authored by Geoff Simmons's avatar Geoff Simmons

safely set the monitoring interval for the Kafka MQ plugin

parent ee16f13e
...@@ -75,13 +75,13 @@ static void ...@@ -75,13 +75,13 @@ static void
*monitor_thread(void *arg) *monitor_thread(void *arg)
{ {
struct timespec t; struct timespec t;
unsigned interval = *((unsigned *) arg); (void) arg;
AN(interval); AN(stats_interval);
/* Convert ms -> struct timespec */ /* Convert ms -> struct timespec */
t.tv_sec = (time_t) interval / 1e3; t.tv_sec = (time_t) stats_interval / 1e3;
t.tv_nsec = (interval % (unsigned) 1e3) * 1e6; t.tv_nsec = (stats_interval % (unsigned) 1e3) * 1e6;
MQ_LOG_Log(LOG_INFO, MQ_LOG_Log(LOG_INFO,
"libtrackrdr-kafka monitor thread running every %u.%03lu secs", "libtrackrdr-kafka monitor thread running every %u.%03lu secs",
t.tv_sec, t.tv_nsec / (unsigned long) 1e6); t.tv_sec, t.tv_nsec / (unsigned long) 1e6);
...@@ -118,11 +118,11 @@ static void ...@@ -118,11 +118,11 @@ static void
} }
int int
MQ_MON_Init(unsigned interval) MQ_MON_Init(void)
{ {
if (interval == 0) if (stats_interval == 0)
return 0; return 0;
return pthread_create(&monitor, NULL, monitor_thread, (void *) &interval); return pthread_create(&monitor, NULL, monitor_thread, NULL);
} }
void void
......
...@@ -161,7 +161,7 @@ MQ_GlobalInit(unsigned nworkers, const char *config_fname) ...@@ -161,7 +161,7 @@ MQ_GlobalInit(unsigned nworkers, const char *config_fname)
} }
if (stats_interval != 0) { if (stats_interval != 0) {
int err = MQ_MON_Init(stats_interval); int err = MQ_MON_Init();
if (err != 0) { if (err != 0) {
snprintf(errmsg, LINE_MAX, "Cannot start monitoring thread: %s", snprintf(errmsg, LINE_MAX, "Cannot start monitoring thread: %s",
strerror(err)); strerror(err));
......
...@@ -77,7 +77,7 @@ void MQ_LOG_SetLevel(int level); ...@@ -77,7 +77,7 @@ void MQ_LOG_SetLevel(int level);
void MQ_LOG_Close(void); void MQ_LOG_Close(void);
/* monitor.c */ /* monitor.c */
int MQ_MON_Init(unsigned interval); int MQ_MON_Init(void);
void MQ_MON_Fini(void); void MQ_MON_Fini(void);
/* zookeeper.c */ /* zookeeper.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment