jbreams/nagmq

Segfault while reload/stop Nagios

micoq opened this issue · 1 comments

Hi,

I've found a little issue : when you try to reload or stop Nagios with NagMQ, it do a segfault @ 0 (null pointer).

You can reproduce this case by using this configuration :

{
"publish": {
"enable": true,
"bind": "tcp://*:7777"
},
"pull": {
"enable": false
},
"reply": {
"enable": false
}
}

So :

  • you don't have a "pull" socket
  • you don't have a "reply" socket
  • but you have a "publish socket"

The problem is in the function handle_startup() (in file mods/common.c) :

The function pthread_create() is called only if a "pull" or a "reply" socket is requested (line 328) but the function pthread_join() is called all the time when Nagios closes (line 353) :

zmq_close(pubext); zmq_term(zmq_ctx); pthread_join(threadid, NULL); // segfault because threadid is not initialised } return 0; }

Here is a little patch :)

zmq_close(pubext); zmq_term(zmq_ctx); if(enablereq || enablepull) pthread_join(threadid, NULL); } return 0; }

Regards,
Michaël

Thanks! This has been committed in aa35ffe