From bcf1e8b07491b48c5372924dbbbad5b8391c6d81 Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Tue, 6 Nov 2018 16:23:51 +0530 Subject: core: Portmap entries showing stale brick entries when bricks are down Problem: pmap is showing stale brick entries after down the brick because of glusterd_brick_rpc_notify call gf_is_service_running before call pmap_registry_remove to ensure about brick instance. Solutiom: 1) Change the condition in gf_is_pid_running to ensure about process existence, use open instead of access to achieve the same 2) Call search_brick_path_from_proc in __glusterd_brick_rpc_notify along with gf_is_service_running Change-Id: Ia663ac61c01fdee6c12f47c0300cdf93f19b6a19 fixes: bz#1646892 Signed-off-by: Mohit Agrawal --- libglusterfs/src/common-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 5d66e8d4207..31759a3e48f 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4015,13 +4015,16 @@ gf_is_pid_running(int pid) char fname[32] = { 0, }; + int fd = -1; snprintf(fname, sizeof(fname), "/proc/%d/cmdline", pid); - if (sys_access(fname, R_OK) != 0) { + fd = sys_open(fname, O_RDONLY, 0); + if (fd < 0) { return _gf_false; } + sys_close(fd); return _gf_true; } -- cgit