Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 75058ee

Browse files
author
Hua Huang
committed
Adding async_disconnecting flag to avoid multiple async rpc disconn
* async_disconnecting is used to check if waiting is needed. * No need to call session_put() in rm_remote_free(). Because at this moment, maybe some other requests are still in progress. Signed-off-by: Hua Huang <[email protected]>
1 parent 60c43dd commit 75058ee

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

rm/rm.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,6 @@ static void rm_remote_free(struct m0_ref *ref)
13851385
{
13861386
struct m0_rm_remote *rem =
13871387
container_of(ref, struct m0_rm_remote, rem_refcnt);
1388-
struct m0_rpc_session *sess = rem->rem_session;
13891388

13901389
/*
13911390
* Free only those remotes who connected to us asking for
@@ -1399,13 +1398,6 @@ static void rm_remote_free(struct m0_ref *ref)
13991398
m0_remotes_tlist_del(rem);
14001399
m0_rm_remote_fini(rem);
14011400
m0_free(rem);
1402-
1403-
/*
1404-
* Note: it seems the session can be NULL only in UTs here.
1405-
* (In particular, at rm-ut:fom-funcs.)
1406-
*/
1407-
if (sess != NULL)
1408-
m0_rpc_service_reverse_session_put(sess, true);
14091401
}
14101402

14111403
M0_INTERNAL void m0_rm_remote_init(struct m0_rm_remote *rem,

rpc/link.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ M0_INTERNAL int m0_rpc_link_init(struct m0_rpc_link *rlink,
615615

616616
rlink->rlk_connected = false;
617617
rlink->rlk_rc = 0;
618+
rlink->rlk_async_disconnecting = false;
618619

619620
rc = m0_net_end_point_create(&net_ep, &mach->rm_tm, ep);
620621
if (rc == 0) {

rpc/link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct m0_rpc_link {
5353
struct m0_mutex rlk_wait_mutex;
5454
m0_time_t rlk_timeout;
5555
bool rlk_connected;
56+
bool rlk_async_disconnecting;
5657
};
5758

5859
enum m0_rpc_link_states {

rpc/service.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ m0_rpc_service_reverse_session_put(struct m0_rpc_session *sess, bool disc)
237237
rlk = container_of(sess, struct m0_rpc_link, rlk_sess);
238238
revc = container_of(rlk, struct m0_reverse_connection, rcf_rlink);
239239

240-
if (revc->rcf_rlink.rlk_connected) {
240+
if (revc->rcf_rlink.rlk_connected &&
241+
!revc->rcf_rlink.rlk_async_disconnecting) {
242+
revc->rcf_rlink.rlk_async_disconnecting = true;
241243
M0_PRE(!m0_clink_is_armed(&revc->rcf_disc_wait));
242244
m0_clink_fini(&revc->rcf_disc_wait);
243245
m0_clink_init(&revc->rcf_disc_wait,
@@ -271,7 +273,8 @@ m0_rpc_service_reverse_sessions_cleanup(struct m0_reqh_service *service)
271273
false);
272274
} m0_tlist_endfor;
273275
m0_tl_teardown(rev_conn, &svc->rps_rev_conns, revc) {
274-
if (m0_clink_is_armed(&revc->rcf_disc_wait)) {
276+
if (m0_clink_is_armed(&revc->rcf_disc_wait) &&
277+
revc->rcf_rlink.rlk_async_disconnecting) {
275278
m0_chan_wait(&revc->rcf_disc_wait);
276279
m0_clink_fini(&revc->rcf_disc_wait);
277280
}

0 commit comments

Comments
 (0)