<div dir="ltr">Merged.<div>Thanks.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 17, 2016 at 10:02 AM, Michael Wang <span dir="ltr"><<a href="mailto:yun.wang@profitbricks.com" target="_blank">yun.wang@profitbricks.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear maintainer, is this patch looks fine to you?<br>
<br>
Regards,<br>
Michael Wang<br>
<div class="HOEnZb"><div class="h5"><br>
On 10/12/2016 10:54 AM, Michael Wang wrote:<br>
><br>
> Inside parse_cmd() the pthread_cleanup_pop() rely on '!r' as the<br>
> indicator of locked or not, while this will be overwritten if the<br>
> handler return failed, and the unlock will be missing.<br>
><br>
> This will lead into the situation that all the following operation<br>
> will trying to hold a lock which will never be released.<br>
><br>
> This patch using a separate flag to record the status of locking to<br>
> make sure the unlock and lock are in pairs.<br>
><br>
> Signed-off-by: Michael Wang <<a href="mailto:yun.wang@profitbricks.com">yun.wang@profitbricks.com</a>><br>
> ---<br>
>  multipathd/cli.c | 4 +++-<br>
>  1 file changed, 3 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/multipathd/cli.c b/multipathd/cli.c<br>
> index e8a9384..50161be 100644<br>
> --- a/multipathd/cli.c<br>
> +++ b/multipathd/cli.c<br>
> @@ -481,6 +481,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout )<br>
>                 tmo.tv_sec = 0;<br>
>         }<br>
>         if (h->locked) {<br>
> +               int locked = 0;<br>
>                 struct vectors * vecs = (struct vectors *)data;<br>
><br>
>                 pthread_cleanup_push(cleanup_<wbr>lock, &vecs->lock);<br>
> @@ -491,10 +492,11 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout )<br>
>                         r = 0;<br>
>                 }<br>
>                 if (r == 0) {<br>
> +                       locked = 1;<br>
>                         pthread_testcancel();<br>
>                         r = h->fn(cmdvec, reply, len, data);<br>
>                 }<br>
> -               pthread_cleanup_pop(!r);<br>
> +               pthread_cleanup_pop(locked);<br>
>         } else<br>
>                 r = h->fn(cmdvec, reply, len, data);<br>
>         free_keys(cmdvec);<br>
><br>
</div></div></blockquote></div><br></div>