summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <Jafaral@users.noreply.github.com>2018-01-18 09:37:24 -0600
committerGitHub <noreply@github.com>2018-01-18 09:37:24 -0600
commit9ee9eb80663fa45c623ad28bf5f08347a65fb12c (patch)
tree238fa6df33ba09a50831997c5b008c7278c4590d
parent81dadaca1a07ce26b41576093c9ac3dd33ffab66 (diff)
parent42d745387a0b75f539b6ad45e32305199b59c53a (diff)
Merge pull request #1645 from qlyoung/fix-cancel-invalid-rw
lib: avoid crash when cancelling invalid rw job
-rw-r--r--lib/thread.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/thread.c b/lib/thread.c
index d26db88550..9d64663d9c 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -919,6 +919,8 @@ struct thread *funcname_thread_add_event(struct thread_master *m,
*/
static void thread_cancel_rw(struct thread_master *master, int fd, short state)
{
+ bool found = false;
+
/* Cancel POLLHUP too just in case some bozo set it */
state |= POLLHUP;
@@ -926,8 +928,18 @@ static void thread_cancel_rw(struct thread_master *master, int fd, short state)
nfds_t i;
for (i = 0; i < master->handler.pfdcount; i++)
- if (master->handler.pfds[i].fd == fd)
+ if (master->handler.pfds[i].fd == fd) {
+ found = true;
break;
+ }
+
+ if (!found) {
+ zlog_debug(
+ "[!] Received cancellation request for nonexistent rw job");
+ zlog_debug("[!] threadmaster: %s | fd: %d",
+ master->name ? master->name : "", fd);
+ return;
+ }
/* NOT out event. */
master->handler.pfds[i].events &= ~(state);