[baobab] connect-server: Make sure to read data before returning



commit 4119a5ceb6b04669cb2f7c9997a4f3786c5bdb25
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Apr 11 15:49:18 2012 +0200

    connect-server: Make sure to read data before returning
    
    When the condition contains both IOCondition.IN and IOCondition.HUP,
    check for data before returning instead of the other way round.

 src/baobab-connect-server.vala |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/baobab-connect-server.vala b/src/baobab-connect-server.vala
index 8c86178..e69c3b3 100644
--- a/src/baobab-connect-server.vala
+++ b/src/baobab-connect-server.vala
@@ -33,25 +33,23 @@ namespace Baobab {
         }
 
         bool on_out_watch (IOChannel channel, IOCondition cond) {
-            if (IOCondition.HUP in cond) {
-                selected(null);
-                return false;
-            }
-
             string? uri = null;
-            try {
-                size_t len;
-                size_t lineend;
-                channel.read_line(out uri, out len, out lineend);
-                if (len > 0) {
-                    uri = uri[0:(int)lineend];
+
+            if (IOCondition.IN in cond) {
+                try {
+                    size_t len;
+                    size_t lineend;
+                    channel.read_line(out uri, out len, out lineend);
+                    if (len > 0) {
+                        uri = uri[0:(int)lineend];
+                    }
+                } catch {
                 }
-            } catch {
-            } finally {
-                selected(uri);
             }
 
-            return true;
+            selected (uri);
+
+            return false;
         }
 
         public void show () {



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