[rygel/wip/basic-management: 20/49] core: Wait for both BasicManagement (out/err) streams to EOF



commit 8cb1463a755c5bd9d243aedce08ee966be060f37
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Fri May 31 15:29:25 2013 +0300

    core: Wait for both BasicManagement (out/err) streams to EOF
    
    Sometimes stdout is closed before an error message is sent to
    stderr: wait for both to close before finishing one iteration.

 src/librygel-core/rygel-bm-test.vala |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-core/rygel-bm-test.vala b/src/librygel-core/rygel-bm-test.vala
index f90c9a8..a91743c 100644
--- a/src/librygel-core/rygel-bm-test.vala
+++ b/src/librygel-core/rygel-bm-test.vala
@@ -68,6 +68,7 @@ internal abstract class Rygel.BMTest : Object {
     protected string[] command;
     protected uint repetitions;
 
+    private uint eof_count;
     private int std_out;
     private int std_err;
     private Pid child_pid;
@@ -110,6 +111,7 @@ internal abstract class Rygel.BMTest : Object {
     private void run_iteration () {
         try {
             init_iteration ();
+            eof_count = 0;
             Process.spawn_async_with_pipes (null,
                                             command,
                                             null,
@@ -142,7 +144,9 @@ internal abstract class Rygel.BMTest : Object {
                 handle_output (line);
 
             if (status == IOStatus.EOF) {
-                finish_iteration ();
+                eof_count++;
+                if (eof_count > 1)
+                    finish_iteration ();
                 return false;
             }
         } catch (Error e) {
@@ -161,10 +165,17 @@ internal abstract class Rygel.BMTest : Object {
             IOStatus status = channel.read_line (out line, null, null);
             if (line != null)
                 handle_error (line);
-            if (status == IOStatus.EOF)
+
+            if (status == IOStatus.EOF) {
+                eof_count++;
+                if (eof_count > 1)
+                    finish_iteration ();
                 return false;
+            }
         } catch (Error e) {
             warning ("Failed readline() from nslookup stderr: %s", e.message);
+            /* TODO set execution_state ? */
+            finish_iteration();
             return false;
         }
 


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