Permalink
Browse files

* Fix crash when monit daemon start delay option was used and monit

  was signalized to stop before the start delay passed. Thanks to
  John Schult for report.




git-svn-id: http://monit.googlecode.com/svn/trunk@351 808b68a2-07de-11de-a1f0-819f45317607
  • Loading branch information...
1 parent e9195ca commit aa491f6ca2d2dd79abebf1e97b6f3a14fd4453e8 mmonit@tildeslash.com committed Mar 27, 2011
Showing with 28 additions and 17 deletions.
  1. +16 −12 CHANGES.txt
  2. +12 −5 monitor.c
View
@@ -9,31 +9,35 @@
Version 5.2.5
-* Fix process match check - when the monitored process failed and was
- restarted by Monit, Monit didn't recognized it is running after the
- restart and reported start failure (similar on stop). Thanks to
- Kenichi Futatsumori for report and helping to root cause the problem.
+* Fix process match check - when the monitored process failed and
+ was restarted by Monit, Monit didn't recognized it is running
+ after the restart and reported start failure (similar on stop).
+ Thanks to Kenichi Futatsumori for report and helping to root
+ cause the problem.
-* Fix Debian #617259: symbolic links in the filesystem check doesn't work.
- Thanks to Sergey B Kirpichev for report.
+* Fix Debian #617259: symbolic links in the filesystem check doesn't
+ work. Thanks to Sergey B Kirpichev for report.
-* Fix Debian bug #614984: smtp protocol test issues both EHLO and HELO.
- Thanks to Sergey B Kirpichev for report.
+* Fix Debian bug #614984: smtp protocol test issues both EHLO and
+ HELO. Thanks to Sergey B Kirpichev for report.
-* Fix bug #32583: Multiple SIP OPTIONS messages use the same header data.
- Thanks to Hugh Waite for patch.
+* Fix bug #32583: Multiple SIP OPTIONS messages use the same header
+ data. Thanks to Hugh Waite for patch.
* Try harder to get FQDN hostname for the host where monit is running.
The hostname in the $HOST variable which is used in the mail sender
may thus change. Thanks to Sergey B Kirpichev for patch.
-* AIX: Fix the time display which was off by GMT difference. Thanks to
- Helen Chen for report.
+* AIX: Fix the time display which was off by GMT difference. Thanks
+ to Helen Chen for report.
* AIX: Fix the M/Monit heartbeat. Thanks to Helen Chen for report.
* Support symbolic link to monit configuration file.
+* Fix crash when monit daemon start delay option was used and monit
+ was signalized to stop before the start delay passed. Thanks to
+ John Schult for report.
View
@@ -124,9 +124,10 @@ Service_T servicelist_conf; /**< The service list in conf file (c. in p.y) */
ServiceGroup_T servicegrouplist;/**< The service group list (created in p.y) */
SystemInfo_T systeminfo; /**< System infomation */
-pthread_t heartbeatThread; /**< M/Monit heartbeat thread */
-pthread_cond_t heartbeatCond; /**< Hearbeat wakeup condition */
-pthread_mutex_t heartbeatMutex; /**< Hearbeat mutex */
+pthread_t heartbeatThread; /**< M/Monit heartbeat thread */
+pthread_cond_t heartbeatCond; /**< Hearbeat wakeup condition */
+pthread_mutex_t heartbeatMutex; /**< Hearbeat mutex */
+static volatile int heartbeatRunning = FALSE; /**< Heartbeat thread flag */
int ptreesize = 0;
int oldptreesize = 0;
@@ -330,11 +331,12 @@ static void do_reinit() {
LogInfo("Awakened by the SIGHUP signal\n");
LogInfo("Reinitializing %s - Control file '%s'\n", prog, Run.controlfile);
- if(Run.mmonits) {
+ if(Run.mmonits && heartbeatRunning) {
if ((status = pthread_cond_signal(&heartbeatCond)) != 0)
LogError("%s: Failed to signal the heartbeat thread -- %s\n", prog, strerror(status));
if ((status = pthread_join(heartbeatThread, NULL)) != 0)
LogError("%s: Failed to stop the heartbeat thread -- %s\n", prog, strerror(status));
+ heartbeatRunning = FALSE;
}
Run.doreload = FALSE;
@@ -388,6 +390,8 @@ static void do_reinit() {
if(Run.mmonits && ((status = pthread_create(&heartbeatThread, NULL, heartbeat, NULL)) != 0))
LogError("%s: Failed to create the heartbeat thread -- %s\n", prog, strerror(status));
+ else
+ heartbeatRunning = TRUE;
}
@@ -481,11 +485,12 @@ static void do_exit() {
if (can_http())
monit_http(STOP_HTTP);
- if(Run.mmonits) {
+ if(Run.mmonits && heartbeatRunning) {
if ((status = pthread_cond_signal(&heartbeatCond)) != 0)
LogError("%s: Failed to signal the heartbeat thread -- %s\n", prog, strerror(status));
if ((status = pthread_join(heartbeatThread, NULL)) != 0)
LogError("%s: Failed to stop the heartbeat thread -- %s\n", prog, strerror(status));
+ heartbeatRunning = FALSE;
}
LogInfo("%s daemon with pid [%d] killed\n", prog, (int)getpid());
@@ -555,6 +560,8 @@ static void do_default() {
if(Run.mmonits && ((status = pthread_create(&heartbeatThread, NULL, heartbeat, NULL)) != 0))
LogError("%s: Failed to create the heartbeat thread -- %s\n", prog, strerror(status));
+ else
+ heartbeatRunning = TRUE;
while (TRUE) {
validate();

0 comments on commit aa491f6

Please sign in to comment.