Re: [libvirt PATCH] tests: fix deadlock in eventtest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 06, 2020 at 13:22:28 +0100, Pavel Hrdina wrote:
> There is a race deadlock in eventtest after the recent rewrite to drop
> GNULIB from libvirt code base.
> 
> The issue happens when the callbacks testPipeReader() or testTimer()
> are called before waitEvents() starts waiting on `eventThreadCond`.
> It will never happen because the callbacks are already done and there
> is nothing that will signal the condition again.
> 
> Reported-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
> ---
>  tests/eventtest.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

[...]

> @@ -185,7 +188,10 @@ waitEvents(int nhandle, int ntimer)
>      VIR_DEBUG("Wait events nhandle %d ntimer %d",
>                nhandle, ntimer);
>      while (ngothandle != nhandle || ngottimer != ntimer) {
> -        pthread_cond_wait(&eventThreadCond, &eventThreadMutex);
> +        while (!eventThreadSignaled)
> +            pthread_cond_wait(&eventThreadCond, &eventThreadMutex);
> +
> +        eventThreadSignaled = 0;

s/0/false/

Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>

>  
>          ngothandle = ngottimer = 0;
>          for (i = 0; i < NUM_FDS; i++) {
> -- 
> 2.24.1
> 





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux