diff options
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
| -rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 36 | 
1 files changed, 27 insertions, 9 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index eef1546cc69..cf6f2fc27ed 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -51,6 +51,7 @@  #include "hashfn.h"  #include "glusterfs-acl.h"  #include "events.h" +#include <sys/types.h>  char *marker_xattrs[] = {"trusted.glusterfs.quota.*",                           "trusted.glusterfs.*.xtime", @@ -1841,6 +1842,9 @@ posix_health_check_thread_proc (void *data)          struct posix_private *priv               = NULL;          uint32_t              interval           = 0;          int                   ret                = -1; +        xlator_t                *top             = NULL; +        xlator_list_t           **trav_p         = NULL; +        int                     count            = 0;          this = data;          priv = this->private; @@ -1852,7 +1856,6 @@ posix_health_check_thread_proc (void *data)          gf_msg_debug (this->name, 0, "health-check thread started, "                  "interval = %d seconds", interval); -          while (1) {                  /* aborting sleep() is a request to exit this thread, sleep()                   * will normally not return when cancelled */ @@ -1889,18 +1892,33 @@ abort:          xlator_notify (this->parents->xlator, GF_EVENT_CHILD_DOWN, this); -        ret = sleep (30); -        if (ret == 0) { +        /* Below code is use to ensure if brick multiplexing is enabled if +           count is more than 1 it means brick mux has enabled +        */ +        if (this->ctx->active) { +                top = this->ctx->active->first; +                for (trav_p = &top->children; *trav_p; +                                               trav_p = &(*trav_p)->next) { +                        count++; +                } +        } + +        if (count == 1) {                  gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED,                          "still alive! -> SIGTERM"); -                kill (getpid(), SIGTERM); -        } +                ret = sleep (30); -        ret = sleep (30); -        if (ret == 0) { +                /* Need to kill the process only while brick mux has not enabled +                */ +                if (ret == 0) +                        kill (getpid(), SIGTERM); + +                ret = sleep (30);                  gf_msg (this->name, GF_LOG_EMERG, 0, P_MSG_HEALTHCHECK_FAILED, -                        "still alive! -> SIGKILL"); -                kill (getpid(), SIGKILL); +                        "still alive! -> SIGTERM"); +                if (ret == 0) +                        kill (getpid(), SIGTERM); +          }          return NULL;  | 
