diff options
| author | anand <anekkunt@redhat.com> | 2015-04-10 16:41:25 +0530 | 
|---|---|---|
| committer | Atin Mukherjee <amukherj@redhat.com> | 2015-06-16 03:33:56 -0700 | 
| commit | c58a15811a82c675a4cc20d664731239daa0c48c (patch) | |
| tree | e24d64aa6eab5ff53f5c959168b1bb047791420c | |
| parent | a824655de117d536b16c20ab8e38dfc698107d6a (diff) | |
glusterd: Stop tcp/ip listeners during  glusterd exit
Problem : Because of race between exit thread and rpc thread
causing the glusterd crash while glusterd exiting/stoping.
Fix : Stop tcp/ip socket listeners in cleanup_and_exit to
avoid new rpc events.
Backport of :
>Change-Id: Ie9280c8c9d7c350a176529375d861432f3de94ac
>BUG: 1209461
>Signed-off-by: anand <anekkunt@redhat.com>
>Reviewed-on: http://review.gluster.org/10197
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Kaushal M <kaushal@redhat.com>
Change-Id: Ibb3d3669e248af8c5284801d7f18c6ee26fe2ef3
BUG: 1230026
Reviewed-on: http://review.gluster.org/11154
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 48 | 
1 files changed, 45 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 54a5fbdbda5..39160c0049b 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1113,8 +1113,38 @@ glusterd_stop_uds_listener (xlator_t *this)          }          unlink (sockfile); -        GF_FREE (conf->uds_rpc); -        conf->uds_rpc = NULL; +        return; +} + + +void +glusterd_stop_listener (xlator_t *this) +{ +        glusterd_conf_t         *conf = NULL; +        rpcsvc_listener_t       *listener = NULL; +        rpcsvc_listener_t       *next = NULL; +        int                      i = 0; + +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); +        conf = this->private; +        GF_VALIDATE_OR_GOTO (this->name, conf, out); + +        gf_log (this->name, GF_LOG_DEBUG, +                "%s function called ", __func__); + +        for (i = 0; i < gd_inet_programs_count; i++) { +              rpcsvc_program_unregister (conf->rpc, gd_inet_programs[i]); +        } + +        list_for_each_entry_safe (listener, next, &conf->rpc->listeners, list) { +                rpcsvc_listener_destroy (listener); +        } + +        (void) rpcsvc_unregister_notify (conf->rpc, +                                         glusterd_rpcsvc_notify, +                                         this); + +out:          return;  } @@ -1743,8 +1773,19 @@ fini (xlator_t *this)          conf = this->private; -        glusterd_stop_uds_listener (this); +        glusterd_stop_uds_listener (this); /*stop unix socket rpc*/ +        glusterd_stop_listener (this);     /*stop tcp/ip socket rpc*/ +#if 0 +       /* Running threads might be using these resourses, we have to cancel/stop +        * running threads before deallocating the memeory, but we don't have +        * control over the running threads to do pthread_cancel(). +        * So memeory freeing handover to kernel. +        */ +        /*TODO: cancel/stop the running threads*/ + +        GF_FREE (conf->uds_rpc); +        GF_FREE (conf->rpc);          FREE (conf->pmap);          if (conf->handle)                  gf_store_handle_destroy (conf->handle); @@ -1754,6 +1795,7 @@ fini (xlator_t *this)          GF_FREE (conf);          this->private = NULL; +#endif  out:          return;  }  | 
