summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorXiubo Li <xiubli@redhat.com>2019-07-26 12:34:52 +0800
committerAmar Tumballi <amarts@redhat.com>2019-07-29 04:43:56 +0000
commit799edc73c3d4f694c365c6a7c27c9ab8eed5f260 (patch)
tree2c135042a67ffc04091fa2adfa1ea5fdf582cd16 /cli
parent26b9c85861f058a4a8335b28f49410ba061e7c1a (diff)
event: rename event_XXX with gf_ prefixed
I hit one crash issue when using the libgfapi. In the libgfapi it will call glfs_poller() --> event_dispatch() in file api/src/glfs.c:721, and the event_dispatch() is defined by libgluster locally, the problem is the name of event_dispatch() is the extremly the same with the one from libevent package form the OS. For example, if a executable program Foo, which will also use and link the libevent and the libgfapi at the same time, I can hit the crash, like: kernel: glfs_glfspoll[68486]: segfault at 1c0 ip 00007fef006fd2b8 sp 00007feeeaffce30 error 4 in libevent-2.0.so.5.1.9[7fef006ed000+46000] The link for Foo is: lib_foo_LADD = -levent $(GFAPI_LIBS) It will crash. This is because the glfs_poller() is calling the event_dispatch() from the libevent, not the libglsuter. The gfapi link info : GFAPI_LIBS = -lacl -lgfapi -lglusterfs -lgfrpc -lgfxdr -luuid If I link Foo like: lib_foo_LADD = $(GFAPI_LIBS) -levent It will works well without any problem. And if Foo call one private lib, such as handler_glfs.so, and the handler_glfs.so will link the GFAPI_LIBS directly, while the Foo won't and it will dlopen(handler_glfs.so), then the crash will be hit everytime. The link info will be: foo_LADD = -levent libhandler_glfs_LIBADD = $(GFAPI_LIBS) I can avoid the crash temporarily by linking the GFAPI_LIBS in Foo too like: foo_LADD = $(GFAPI_LIBS) -levent libhandler_glfs_LIBADD = $(GFAPI_LIBS) But this is ugly since the Foo won't use any APIs from the GFAPI_LIBS. And in some cases when the --as-needed link option is added(on many dists it is added as default), then the crash is back again, the above workaround won't work. Fixes: #699 Change-Id: I38f0200b941bd1cff4bf3066fca2fc1f9a5263aa Signed-off-by: Xiubo Li <xiubli@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rl.c6
-rw-r--r--cli/src/cli.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/cli/src/cli-rl.c b/cli/src/cli-rl.c
index b6f87b189aa..7a38a0b882a 100644
--- a/cli/src/cli-rl.c
+++ b/cli/src/cli-rl.c
@@ -112,7 +112,7 @@ cli_rl_stdin(int fd, int idx, int gen, void *data, int poll_out, int poll_in,
rl_callback_read_char();
- event_handled(state->ctx->event_pool, fd, idx, gen);
+ gf_event_handled(state->ctx->event_pool, fd, idx, gen);
return;
}
@@ -379,8 +379,8 @@ cli_rl_enable(struct cli_state *state)
goto out;
}
- ret = event_register(state->ctx->event_pool, 0, cli_rl_stdin, state, 1, 0,
- 0);
+ ret = gf_event_register(state->ctx->event_pool, 0, cli_rl_stdin, state, 1,
+ 0, 0);
if (ret == -1)
goto out;
diff --git a/cli/src/cli.c b/cli/src/cli.c
index d6f2e4a1d42..fac32d3e9ca 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -122,8 +122,8 @@ glusterfs_ctx_defaults_init(glusterfs_ctx_t *ctx)
goto out;
}
- ctx->event_pool = event_pool_new(DEFAULT_EVENT_POOL_SIZE,
- STARTING_EVENT_THREADS);
+ ctx->event_pool = gf_event_pool_new(DEFAULT_EVENT_POOL_SIZE,
+ STARTING_EVENT_THREADS);
if (!ctx->event_pool) {
gf_log("cli", GF_LOG_ERROR, "Failed to create event pool.");
goto out;
@@ -862,7 +862,7 @@ main(int argc, char *argv[])
if (ret)
goto out;
- ret = event_dispatch(ctx->event_pool);
+ ret = gf_event_dispatch(ctx->event_pool);
out:
// glusterfs_ctx_destroy (ctx);