[rygel/wip/basic-management: 49/68] core: BasicManagement NSLookup: handle case of unresolved name server



commit 490606f5fca11f60bc1e9e9e1e560ea65b8077e5
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Fri May 31 15:31:12 2013 +0300

    core: BasicManagement NSLookup: handle case of unresolved name server

 src/librygel-core/rygel-bm-test-nslookup.vala |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/src/librygel-core/rygel-bm-test-nslookup.vala b/src/librygel-core/rygel-bm-test-nslookup.vala
index 4005a26..a769cad 100644
--- a/src/librygel-core/rygel-bm-test-nslookup.vala
+++ b/src/librygel-core/rygel-bm-test-nslookup.vala
@@ -200,22 +200,33 @@ internal class Rygel.BMTestNSLookup : BMTest {
 
     protected override void finish_iteration () {
         switch (execution_state) {
-            case ExecutionState.IN_PROGRESS:
-                var execution_time = (uint)Math.round(timer.elapsed (null) * 1000);
-                results[results.length - 1].execution_time = execution_time;
-                break;
             case ExecutionState.SPAWN_FAILED:
                 generic_status = GenericStatus.ERROR_INTERNAL;
                 additional_info = "Failed spawn nslookup";
                 results[results.length - 1].status = ResultStatus.ERROR_OTHER;
                 break;
             default:
+                var execution_time = (uint)Math.round(timer.elapsed (null) * 1000);
+                results[results.length - 1].execution_time = execution_time;
                 break;
         }
 
         base.finish_iteration ();
     }
 
+    protected override void handle_error (string line) {
+        var result = results[results.length - 1];
+
+        if (line.contains ("couldn't get address for")) {
+            generic_status = GenericStatus.ERROR_DNS_SERVER_NOT_RESOLVED;
+            result.status = ResultStatus.ERROR_DNS_SERVER_NOT_AVAILABLE;
+            execution_state = ExecutionState.COMPLETED;
+        }
+
+        /* there has to be a nicer way to do this... */
+        results[results.length - 1] = result;
+    }
+
     protected override void handle_output (string line) {
         var result = results[results.length - 1];
         line.strip();
@@ -248,7 +259,7 @@ internal class Rygel.BMTestNSLookup : BMTest {
         } else if (line.contains ("couldn't get address for")) {
             generic_status = GenericStatus.ERROR_DNS_SERVER_NOT_RESOLVED;
             result.status = ResultStatus.ERROR_DNS_SERVER_NOT_AVAILABLE;
-            /* TODO should cancel here: future iterations won't help */
+            execution_state = ExecutionState.COMPLETED;
         } else if (line.contains ("no servers could be reached")) {
             result.status = ResultStatus.ERROR_DNS_SERVER_NOT_AVAILABLE;
         }


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