[rygel] core: Error handling of upload file writing



commit a258ac8229ff8a123c60cfed357997a3960f3df1
Author: Grzegorz Grabowski <grzegorz grabowski comarch com>
Date:   Thu Oct 27 14:56:00 2011 +0200

    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.

 src/rygel/rygel-http-post.vala    |   10 +++++++++-
 src/rygel/rygel-http-request.vala |    3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
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
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]