[rygel] core: Make sure file is closed after HTTP POST



commit 9a6a937c43cbd14e44eb4645adb44a858b9c9f8e
Author: Jens Georg <mail jensge org>
Date:   Fri May 20 19:12:57 2011 +0200

    core: Make sure file is closed after HTTP POST
    
    Preparation for https://bugzilla.gnome.org/show_bug.cgi?id=635765
    which is already applied on some systems. This causes the back-ends
    not to get CHANGES_DONE hint until the file is really closed.

 src/rygel/rygel-http-post.vala |   51 ++++++++++++++++++++++-----------------
 1 files changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/src/rygel/rygel-http-post.vala b/src/rygel/rygel-http-post.vala
index b3bd44d..66b83e7 100644
--- a/src/rygel/rygel-http-post.vala
+++ b/src/rygel/rygel-http-post.vala
@@ -88,31 +88,38 @@ internal class Rygel.HTTPPost : HTTPRequest {
             return;
         }
 
-        var main_loop = new MainLoop ();
+        try {
+            this.stream.close (this.cancellable);
+
+            var main_loop = new MainLoop ();
+
+            this.item.parent.container_updated.connect ((container) => {
+                main_loop.quit ();
+            });
+
+            var timeout_id = Timeout.add_seconds (5, () => {
+                debug ("Timeout while waiting for 'updated' signal on '%s'.",
+                       this.item.parent.id);
+                main_loop.quit ();
 
-        this.item.parent.container_updated.connect ((container) => {
-            main_loop.quit ();
-        });
+                return false;
+            });
 
-        var timeout_id = Timeout.add_seconds (5, () => {
-            debug ("Timeout while waiting for 'updated' signal on '%s'.",
+            debug ("Waiting for update signal from container '%s' after pushing" +
+                   " content to its child item '%s'..",
+                   this.item.parent.id,
+                   this.item.id);
+            main_loop.run ();
+            Source.remove (timeout_id);
+            debug ("Finished waiting for update signal from container '%s'",
                    this.item.parent.id);
-            main_loop.quit ();
-
-            return false;
-        });
-
-        debug ("Waiting for update signal from container '%s' after pushing" +
-               " content to its child item '%s'..",
-               this.item.parent.id,
-               this.item.id);
-        main_loop.run ();
-        Source.remove (timeout_id);
-        debug ("Finished waiting for update signal from container '%s'",
-               this.item.parent.id);
-
-        this.end (KnownStatusCode.OK);
-        this.handle_continue ();
+
+            this.end (KnownStatusCode.OK);
+        } catch (Error error) {
+            this.end (KnownStatusCode.INTERNAL_SERVER_ERROR);
+        } finally {
+            this.handle_continue ();
+        }
     }
 
     private void on_got_chunk (Message msg, Buffer chunk) {



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