[monit-dev] [monit] r338 committed - * Fix process match check - when the monitored process failed and was...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[monit-dev] [monit] r338 committed - * Fix process match check - when the monitored process failed and was...

monit-2
Revision: 338
Author:   [hidden email]
Date:     Fri Mar 18 11:15:53 2011
Log:      * 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.


http://code.google.com/p/monit/source/detail?r=338

Modified:
  /trunk/CHANGES.txt
  /trunk/control.c

=======================================
--- /trunk/CHANGES.txt Tue Mar  8 01:09:16 2011
+++ /trunk/CHANGES.txt Fri Mar 18 11:15:53 2011
@@ -9,6 +9,11 @@

  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 bug #32583: Multiple SIP OPTIONS messages use the same header data.
    Thanks to Hugh Waite for patch.

=======================================
--- /trunk/control.c Wed Jan 19 10:40:32 2011
+++ /trunk/control.c Fri Mar 18 11:15:53 2011
@@ -58,6 +58,7 @@
  #endif

  #include "monitor.h"
+#include "process.h"
  #include "net.h"
  #include "socket.h"
  #include "event.h"
@@ -459,22 +460,28 @@
   * @param service A Service to wait for
   */
  static void wait_start(Service_T s) {
-  time_t timeout = time(NULL) + s->start->timeout;
+  int            isrunning = FALSE;
+  int            ptreesize = 0;
+  int            oldptreesize = 0;
+  ProcessTree_T *ptree = NULL;
+  ProcessTree_T *oldptree = NULL;
+  time_t         timeout = time(NULL) + s->start->timeout;

    ASSERT(s);

    while ((time(NULL) < timeout) && !Run.stopped) {
-    if (Util_isProcessRunning(s))
+    initprocesstree(&ptree, &ptreesize, &oldptree, &oldptreesize); //  
Reinitialize the process tree for match test
+    isrunning = Util_isProcessRunning(s);
+    delprocesstree(&oldptree, oldptreesize);
+    if (isrunning)
        break;
      sleep(1);
    }

-  if (!Util_isProcessRunning(s))
+  if (! isrunning)
      Event_post(s, Event_Exec, STATE_FAILED, s->action_EXEC, "failed to  
start");
    else
      Event_post(s, Event_Exec, STATE_SUCCEEDED, s->action_EXEC, "started");
-
-  return;
  }


@@ -488,17 +495,25 @@
   * @return TRUE if the service was stopped otherwise FALSE
   */
  static int wait_stop(Service_T s) {
-  time_t timeout = time(NULL) + s->stop->timeout;
+  int            isrunning = TRUE;
+  int            ptreesize = 0;
+  int            oldptreesize = 0;
+  ProcessTree_T *ptree = NULL;
+  ProcessTree_T *oldptree = NULL;
+  time_t         timeout = time(NULL) + s->stop->timeout;

    ASSERT(s);

    while ((time(NULL) < timeout) && !Run.stopped) {
-    if (!Util_isProcessRunning(s))
+    initprocesstree(&ptree, &ptreesize, &oldptree, &oldptreesize); //  
Reinitialize the process tree for match test
+    isrunning = Util_isProcessRunning(s);
+    delprocesstree(&oldptree, oldptreesize);
+    if (! isrunning)
        break;
      sleep(1);
    }

-  if (Util_isProcessRunning(s)) {
+  if (isrunning) {
      Event_post(s, Event_Exec, STATE_FAILED, s->action_EXEC, "failed to  
stop");
      return FALSE;
    } else {

_______________________________________________
monit-dev mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monit-dev