From: Serge Petrenko <sergepetrenko@tarantool.org>
To: vdavydov.dev@gmail.com
Cc: georgy@tarantool.org, kostja@tarantool.org,
tarantool-patches@freelists.org,
Serge Petrenko <sergepetrenko@tarantool.org>
Subject: [PATCH] replication: fix assertion in relay_cancel()
Date: Fri, 17 Aug 2018 16:59:37 +0300 [thread overview]
Message-ID: <20180817135937.37840-1-sergepetrenko@tarantool.org> (raw)
If relay thread is already exiting (but hadn't executed relay_stop()
yet) and relay_cancel() is called we may encounter an error trying to
call pthread_cancel() after the thread has exited. Handle this case.
Follow-up #3485
---
https://github.com/tarantool/tarantool/issues/3485
https://github.com/tarantool/tarantool/tree/sp/relay-cancel-fix
src/box/relay.cc | 3 ++-
src/tt_pthread.h | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/box/relay.cc b/src/box/relay.cc
index b9919ea86..138e66dd5 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -203,7 +203,8 @@ relay_cancel(struct relay *relay)
{
/* Check that the thread is running first. */
if (relay->cord.id != 0) {
- tt_pthread_cancel(relay->cord.id);
+ if (tt_pthread_cancel(relay->cord.id) == ESRCH)
+ return;
tt_pthread_join(relay->cord.id, NULL);
}
}
diff --git a/src/tt_pthread.h b/src/tt_pthread.h
index d83694460..40b43b112 100644
--- a/src/tt_pthread.h
+++ b/src/tt_pthread.h
@@ -279,7 +279,8 @@
#define tt_pthread_cancel(thread) \
({ int e__ = pthread_cancel(thread); \
- tt_pthread_error(e__); \
+ assert(e__ == 0 || e__ == ESRCH); \
+ e__; \
})
#define tt_pthread_key_create(key, dtor) \
--
2.15.2 (Apple Git-101.1)
next reply other threads:[~2018-08-17 13:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-17 13:59 Serge Petrenko [this message]
2018-08-17 15:06 ` Vladimir Davydov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180817135937.37840-1-sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=georgy@tarantool.org \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH] replication: fix assertion in relay_cancel()' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox