From: Grzegorz Grabowski Date: Thu, 27 Oct 2011 12:56:00 +0000 (+0200) Subject: core: Error handling of upload file writing X-Git-Tag: RYGEL_0_13_0~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a258ac8229ff8a123c60cfed357997a3960f3df1;p=profile%2Fivi%2Frygel.git core: Error handling of upload file writing If stream.write_all method threw an exception Rygel crashed. It happened because on_got_body and on_got_chunk signals came after HTTPPost object transitioned to finished state. The fix disconnects from these signals after file writing errors occurs since there is no recovery from such situation which in real happens only when there is no disk space or max file size is limited. --- diff --git a/src/rygel/rygel-http-post.vala b/src/rygel/rygel-http-post.vala index 887cec4..5a3a5f0 100644 --- a/src/rygel/rygel-http-post.vala +++ b/src/rygel/rygel-http-post.vala @@ -204,7 +204,9 @@ internal class Rygel.HTTPPost : HTTPRequest { try { this.stream.write_all (chunk.data, null, this.cancellable); } catch (Error error) { - this.handle_error (error); + this.disconnect_message_signals (); + this.handle_error ( + new HTTPRequestError.INTERNAL_SERVER_ERROR (error.message)); this.handle_continue (); } } @@ -217,5 +219,11 @@ internal class Rygel.HTTPPost : HTTPRequest { var queue = ItemRemovalQueue.get_default (); yield queue.remove_now (this.item, null); } + + private void disconnect_message_signals () { + this.msg.got_body.disconnect (this.on_got_body); + this.msg.got_chunk.disconnect (this.on_got_chunk); + } + } diff --git a/src/rygel/rygel-http-request.vala b/src/rygel/rygel-http-request.vala index 1a79065..93ef830 100644 --- a/src/rygel/rygel-http-request.vala +++ b/src/rygel/rygel-http-request.vala @@ -26,7 +26,8 @@ internal errordomain Rygel.HTTPRequestError { UNACCEPTABLE = Soup.KnownStatusCode.NOT_ACCEPTABLE, BAD_REQUEST = Soup.KnownStatusCode.BAD_REQUEST, - NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND + NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND, + INTERNAL_SERVER_ERROR = Soup.KnownStatusCode.INTERNAL_SERVER_ERROR } /**