[pulseaudio-discuss] [PATCH] iochannel: Avoid unnecessary wakeup after successful write

David Henningsson david.henningsson at canonical.com
Sun Jun 16 23:56:34 PDT 2013


On 06/17/2013 08:04 AM, David Henningsson wrote:
> On 06/15/2013 09:45 PM, Jan Alexander Steffens wrote:
>> On Fri, Jun 14, 2013 at 12:56 PM, Tanu Kaskinen
>> <tanu.kaskinen at linux.intel.com> wrote:
>>> On Thu, 2013-06-13 at 14:26 +0200, David Henningsson wrote:
>>>> To save some CPU (in low latency scenarios), don't re-enable the
>>>> "writable" event after it has succeeded. It is very likely the next
>>>> write will succeed right away too.
>>>>
>>>> This means that we always need to handle EAGAIN/EWOULDBLOCK as a
>>>> successful write of 0 bytes, so I also verified that all callers to
>>>> pa_iochannel_write handled this correctly.
>>>>
>>>> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
>>>
>>> Thanks, applied.
>>>
>>>> diff --git a/src/pulsecore/ioline.c b/src/pulsecore/ioline.c
>>>> index a18188d..e4d2604 100644
>>>> --- a/src/pulsecore/ioline.c
>>>> +++ b/src/pulsecore/ioline.c
>>>> @@ -351,10 +351,7 @@ static int do_write(pa_ioline *l) {
>>>>
>>>>       while (l->io && !l->dead && pa_iochannel_is_writable(l->io) &&
>>>> l->wbuf_valid_length > 0) {
>>>>
>>>> -        if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index,
>>>> l->wbuf_valid_length)) <= 0) {
>>>> -
>>>> -            if (r < 0 && errno == EAGAIN)
>>>> -                break;
>>>> +        if ((r = pa_iochannel_write(l->io, l->wbuf+l->wbuf_index,
>>>> l->wbuf_valid_length)) < 0) {
>>>>
>>>>               if (r < 0 && errno != EPIPE)
>>>
>>> r is always less than zero here, so I removed the first condition.
>>>
>>> --
>>> Tanu
>>
>> Totem does not play with this patch applied. GNOME Shell also suffers
>> from hangs.
>>
>> Reverting it restores operation.
>>
>
> Thanks for the quick testing, much appreciated! It looks like totem
> hangs for about 30 seconds or so here, and then the file plays back
> correctly. I'll probe a bit deeper here and see if I can understand
> what's going on. Thanks again!

Ok, so I've just committed the attached patch, which should fix it. I'll 
go through the other iochannel users later today and see if they suffer 
from the same problem.

Again thanks for the heads up :-)


-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-pstream-Fixup-hangs-caused-by-recent-iochannel-patch.patch
Type: text/x-patch
Size: 1348 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20130617/a6f97543/attachment.bin>


More information about the pulseaudio-discuss mailing list