LP #1702330: thread_group_close does not unlock mutex in error branches

Description

**Reported in Launchpad by Laurynas Biveinis last update 30-11-2017 13:44:09

Spotted over at MariaDB:

https://github.com/MariaDB/server/pull/413

diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc
index 6075c758e405..0ffe08a80518 100644
— a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -979,24 +979,26 @@ static void thread_group_close(thread_group_t *thread_group)

if (pipe(thread_group->shutdown_pipe))
{

  • DBUG_VOID_RETURN;
    + goto end;
    }


/* Wake listener */
if (io_poll_associate_fd(thread_group->pollfd,
thread_group->shutdown_pipe[0], NULL))
{

  • DBUG_VOID_RETURN;
    + goto end;
    + }
    + {
    + char c= 0;
    + if (write(thread_group->shutdown_pipe[1], &c, 1) < 0)
    + goto end;
    }

  • char c= 0;

  • if (write(thread_group->shutdown_pipe[1], &c, 1) < 0)

  • DBUG_VOID_RETURN;
    -
    /* Wake all workers. */
    while(wake_thread(thread_group) == 0)
    {
    }


+end:
mysql_mutex_unlock(&thread_group->mutex);

DBUG_VOID_RETURN;

Environment

None

Smart Checklist

Activity

Show:
Done

Details

Assignee

Reporter

Priority

Smart Checklist

Created January 21, 2018 at 6:06 AM
Updated January 21, 2018 at 6:06 AM
Resolved January 21, 2018 at 6:06 AM