From b2792d783745ec726a00c4805402a77870549156 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Mon, 17 Jun 2013 08:52:07 +0200 Subject: [PATCH] pstream: Fixup hangs caused by recent iochannel patch Now that we don't *always* get a callback after having written something, make sure we can continue writing as long as it fully succeeds. Signed-off-by: David Henningsson --- src/pulsecore/pstream.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c index 9463437..6cf4394 100644 --- a/src/pulsecore/pstream.c +++ b/src/pulsecore/pstream.c @@ -187,9 +187,12 @@ static void do_pstream_read_write(pa_pstream *p) { } else if (!p->dead && pa_iochannel_is_hungup(p->io)) goto fail; - if (!p->dead && pa_iochannel_is_writable(p->io)) { - if (do_write(p) < 0) + while (!p->dead && pa_iochannel_is_writable(p->io)) { + int r = do_write(p); + if (r < 0) goto fail; + if (r == 0) + break; } pa_pstream_unref(p); @@ -634,7 +637,7 @@ static int do_write(pa_pstream *p) { p->drain_callback(p, p->drain_callback_userdata); } - return 0; + return (size_t) r == l ? 1 : 0; fail: -- 2.7.4