From: Zeeshan Ali (Khattak) Date: Wed, 17 Mar 2010 14:19:45 +0000 (+0200) Subject: core: More reliable way to wait for idle handlers X-Git-Tag: RYGEL_0_5_2~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a082475116f0fb1ddaef252c2b8cccf9f4cd999d;p=profile%2Fivi%2Frygel.git core: More reliable way to wait for idle handlers Instead of keeping the ID of the last installed idle handler and then removing it at the end, just add a new idle hander to end the response so the response is ended after all the idle handlers have been called. This fixes the issue of LiveResponse not sending all the bytes to the client before closing the socket on EOS. --- diff --git a/src/rygel/rygel-live-response.vala b/src/rygel/rygel-live-response.vala index c331656..e764fcb 100644 --- a/src/rygel/rygel-live-response.vala +++ b/src/rygel/rygel-live-response.vala @@ -33,7 +33,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse { private HTTPSeek time_range; - private uint idle_id; private SourceFunc run_continue; public LiveResponse (Soup.Server server, @@ -66,11 +65,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse { public override void end (bool aborted, uint status) { this.pipeline.set_state (State.NULL); - if (this.idle_id != 0) { - Source.remove (this.idle_id); - this.idle_id = 0; - } - if (!aborted) { this.msg.response_body.complete (); } @@ -153,12 +147,10 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse { private void on_new_buffer (Element sink, Buffer buffer, Pad pad) { - this.idle_id = Idle.add_full (Priority.HIGH_IDLE, - () => { + Idle.add_full (Priority.HIGH_IDLE, + () => { this.push_data (buffer.data, buffer.size); - this.idle_id = 0; - return false; }); } @@ -208,7 +200,12 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse { } if (!ret) { - this.end (false, Soup.KnownStatusCode.NONE); + Idle.add_full (Priority.HIGH_IDLE, + () => { + this.end (false, Soup.KnownStatusCode.NONE); + + return false; + }); } return ret;