diff options
author | Xiubo Li <xiubli@redhat.com> | 2019-07-26 12:34:52 +0800 |
---|---|---|
committer | Rinku Kothiya <rkothiya@redhat.com> | 2019-08-21 06:13:38 +0000 |
commit | acbabe3d916d763a0bb13e7df876cac61ca5b160 (patch) | |
tree | 8eeb15421811083a19c49bc3322500febbe53a5a /rpc | |
parent | d89199919265480e43172dd3883c20ee24d46bde (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.
Backport of:
> https://review.gluster.org/#/c/glusterfs/+/23110/
> Change-Id: I38f0200b941bd1cff4bf3066fca2fc1f9a5263aa
> Fixes: #699
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
Change-Id: I38f0200b941bd1cff4bf3066fca2fc1f9a5263aa
updates: bz#1740519
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 799edc73c3d4f694c365c6a7c27c9ab8eed5f260)
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/rpc-lib/src/autoscale-threads.c | 2 | ||||
-rw-r--r-- | rpc/rpc-transport/socket/src/socket.c | 50 |
2 files changed, 26 insertions, 26 deletions
diff --git a/rpc/rpc-lib/src/autoscale-threads.c b/rpc/rpc-lib/src/autoscale-threads.c index 2c53ebbf40e..a954ae7a27a 100644 --- a/rpc/rpc-lib/src/autoscale-threads.c +++ b/rpc/rpc-lib/src/autoscale-threads.c @@ -18,5 +18,5 @@ rpcsvc_autoscale_threads(glusterfs_ctx_t *ctx, rpcsvc_t *rpc, int incr) int thread_count = pool->eventthreadcount; pool->auto_thread_count += incr; - (void)event_reconfigure_threads(pool, thread_count + incr); + (void)gf_event_reconfigure_threads(pool, thread_count + incr); } diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index a5a1f2db88d..2fbcbf4a882 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -1179,7 +1179,7 @@ __socket_reset(rpc_transport_t *this) memset(&priv->incoming, 0, sizeof(priv->incoming)); - event_unregister_close(this->ctx->event_pool, priv->sock, priv->idx); + gf_event_unregister_close(this->ctx->event_pool, priv->sock, priv->idx); priv->sock = -1; priv->idx = -1; @@ -1368,8 +1368,8 @@ __socket_ioq_churn(rpc_transport_t *this) if (list_empty(&priv->ioq)) { /* all pending writes done, not interested in POLLOUT */ - priv->idx = event_select_on(this->ctx->event_pool, priv->sock, - priv->idx, -1, 0); + priv->idx = gf_event_select_on(this->ctx->event_pool, priv->sock, + priv->idx, -1, 0); } out: @@ -2626,7 +2626,7 @@ socket_event_poll_in(rpc_transport_t *this, gf_boolean_t notify_handled) } if (notify_handled && (ret != -1)) - event_handled(ctx->event_pool, priv->sock, priv->idx, priv->gen); + gf_event_handled(ctx->event_pool, priv->sock, priv->idx, priv->gen); if (pollin) { rpc_transport_ref(this); @@ -2740,10 +2740,10 @@ ssl_rearm_event_fd(rpc_transport_t *this) fd = priv->sock; if (priv->ssl_error_required == SSL_ERROR_WANT_READ) - event_select_on(ctx->event_pool, fd, idx, 1, -1); + gf_event_select_on(ctx->event_pool, fd, idx, 1, -1); if (priv->ssl_error_required == SSL_ERROR_WANT_WRITE) - event_select_on(ctx->event_pool, fd, idx, -1, 1); - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_select_on(ctx->event_pool, fd, idx, -1, 1); + gf_event_handled(ctx->event_pool, fd, idx, gen); } static int @@ -2777,8 +2777,8 @@ ssl_handle_server_connection_attempt(rpc_transport_t *this) ret = ssl_complete_connection(this); if (ret == 0) { /* nothing to do */ - event_select_on(ctx->event_pool, fd, idx, 1, 0); - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_select_on(ctx->event_pool, fd, idx, 1, 0); + gf_event_handled(ctx->event_pool, fd, idx, gen); ret = 1; } else { if (errno == EAGAIN) { @@ -2832,7 +2832,7 @@ ssl_handle_client_connection_attempt(rpc_transport_t *this) ret = ssl_complete_connection(this); if (ret == 0) { ret = socket_connect_finish(this); - event_select_on(ctx->event_pool, fd, idx, 1, 0); + gf_event_select_on(ctx->event_pool, fd, idx, 1, 0); gf_log(this->name, GF_LOG_TRACE, ">>> completed client connect"); } else { if (errno == EAGAIN) { @@ -2901,7 +2901,7 @@ socket_handle_client_connection_attempt(rpc_transport_t *this) * return 1 */ ret = 1; - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_handled(ctx->event_pool, fd, idx, gen); } } return ret; @@ -2937,7 +2937,7 @@ socket_complete_connection(rpc_transport_t *this) * socket_server_event_handler() */ priv->accepted = _gf_true; - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_handled(ctx->event_pool, fd, idx, gen); ret = 1; } else { ret = socket_handle_client_connection_attempt(this); @@ -3051,7 +3051,7 @@ socket_event_handler(int fd, int idx, int gen, void *data, int poll_in, rpc_transport_unref(this); } else if (!notify_handled) { - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_handled(ctx->event_pool, fd, idx, gen); } out: @@ -3112,7 +3112,7 @@ socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in, new_sock = sys_accept(priv->sock, SA(&new_sockaddr), &addrlen, aflags); - event_handled(ctx->event_pool, fd, idx, gen); + gf_event_handled(ctx->event_pool, fd, idx, gen); if (new_sock == -1) { gf_log(this->name, GF_LOG_WARNING, "accept on %d failed (%s)", @@ -3278,7 +3278,7 @@ socket_server_event_handler(int fd, int idx, int gen, void *data, int poll_in, ret = rpc_transport_notify(this, RPC_TRANSPORT_ACCEPT, new_trans); if (ret != -1) { - new_priv->idx = event_register( + new_priv->idx = gf_event_register( ctx->event_pool, new_sock, socket_event_handler, new_trans, 1, 0, new_trans->notify_poller_death); if (new_priv->idx == -1) { @@ -3655,9 +3655,9 @@ socket_connect(rpc_transport_t *this, int port) refd = _gf_true; this->listener = this; - priv->idx = event_register(ctx->event_pool, priv->sock, - socket_event_handler, this, 1, 1, - this->notify_poller_death); + priv->idx = gf_event_register(ctx->event_pool, priv->sock, + socket_event_handler, this, 1, 1, + this->notify_poller_death); if (priv->idx == -1) { gf_log("", GF_LOG_WARNING, "failed to register the event; " @@ -3831,9 +3831,9 @@ socket_listen(rpc_transport_t *this) rpc_transport_ref(this); - priv->idx = event_register(ctx->event_pool, priv->sock, - socket_server_event_handler, this, 1, 0, - this->notify_poller_death); + priv->idx = gf_event_register(ctx->event_pool, priv->sock, + socket_server_event_handler, this, 1, 0, + this->notify_poller_death); if (priv->idx == -1) { gf_log(this->name, GF_LOG_WARNING, @@ -3902,8 +3902,8 @@ socket_submit_outgoing_msg(rpc_transport_t *this, rpc_transport_msg_t *msg) } if (need_poll_out) { /* first entry to wait. continue writing on POLLOUT */ - priv->idx = event_select_on(ctx->event_pool, priv->sock, priv->idx, - -1, 1); + priv->idx = gf_event_select_on(ctx->event_pool, priv->sock, + priv->idx, -1, 1); } } unlock: @@ -4020,8 +4020,8 @@ socket_throttle(rpc_transport_t *this, gf_boolean_t onoff) * registered fd mapping. */ if (priv->connected == 1) - priv->idx = event_select_on(this->ctx->event_pool, priv->sock, - priv->idx, (int)!onoff, -1); + priv->idx = gf_event_select_on(this->ctx->event_pool, priv->sock, + priv->idx, (int)!onoff, -1); } pthread_mutex_unlock(&priv->out_lock); return 0; |