[pulseaudio-discuss] [Patch] Infinite loop in mainloop

Colin Guthrie gmane at colin.guthr.ie
Mon Jan 3 01:40:08 PST 2011


'Twas brillig, and Marcel at 01/01/11 15:50 did gyre and gimble:
> I am porting pulseaudio to OS/2. During this I run into trouble with the
> mainloop occasionally eating up all CPU resources. It turned out to be
> an inconsistency in the internal state of the mainloop.
> m->wakeup_requested was 0 while the wakup pipe was ready. In fact most
> probably there is still a race condition somewhere in the code.
> 
> However, the following patch will help to recover from this
> inconsistencies more gracefully, especially if the mainloop is running
> at high priority.
> 
> In mainloop.c, function dispatch_pollfds before the final return
> statement I inserted the following lines:
> 
>         r++;
>         k--;
>     }
> 
> +    /* better recovery from errors */
> +    if (k > (m->wakeup_requested != 0) && !m->quit) {
> +        pa_log_error("Error poll returned %i more pollfds than ready
> IO/wakeup events. => Check wakeup pipe, rebuilding pollfds.",
> +            k - (m->wakeup_requested != 0));
> +        m->wakeup_requested = 1;
> +        m->rebuild_pollfds = TRUE;
> +    }
> 
>     return r;
> }
> 
> (Sorry git is not available for OS/2 so I can't simply create a diff.)

Thanks for this Marcel.

I'm not overly familiar with that code, so hopefully this patch will be
reviewed/commented on by some one else so I can be confident of applying
it :)

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list