[ovs-dev] [PATCH v2] ovn-northd: Ability to detach on Windows.

Gurucharan Shetty shettyg at nicira.com
Mon Aug 17 22:44:49 UTC 2015


A unit test for ovn-northd was hanging because ovn-northd
running on Windows failed to detach. The detach function
for Windows is implemented inside "service_start()".

Also handle Windows services.

Reported-by: Alex Wang <alexw at nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 ovn/controller-vtep/ovn-controller-vtep.c |    5 +++++
 ovn/controller/ovn-controller.c           |    5 +++++
 ovn/northd/ovn-northd.c                   |    5 +++++
 3 files changed, 15 insertions(+)

diff --git a/ovn/controller-vtep/ovn-controller-vtep.c b/ovn/controller-vtep/ovn-controller-vtep.c
index a3b0f96..9a3f03b 100644
--- a/ovn/controller-vtep/ovn-controller-vtep.c
+++ b/ovn/controller-vtep/ovn-controller-vtep.c
@@ -58,6 +58,7 @@ main(int argc, char *argv[])
 
     ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
+    service_start(&argc, &argv);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
 
@@ -106,6 +107,9 @@ main(int argc, char *argv[])
         ovsdb_idl_loop_commit_and_wait(&vtep_idl_loop);
         ovsdb_idl_loop_commit_and_wait(&ovnsb_idl_loop);
         poll_block();
+        if (should_service_stop()) {
+            exiting = true;
+        }
     }
 
     /* It's time to exit.  Clean up the databases. */
@@ -138,6 +142,7 @@ main(int argc, char *argv[])
 
     free(ovnsb_remote);
     free(vtep_remote);
+    service_stop();
 
     exit(retval);
 }
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 8e93a0f..34d7660 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -124,6 +124,7 @@ main(int argc, char *argv[])
 
     ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
+    service_start(&argc, &argv);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
 
@@ -208,6 +209,9 @@ main(int argc, char *argv[])
             ofctrl_wait();
         }
         poll_block();
+        if (should_service_stop()) {
+            exiting = true;
+        }
     }
 
     /* It's time to exit.  Clean up the databases. */
@@ -246,6 +250,7 @@ main(int argc, char *argv[])
 
     free(ovnsb_remote);
     free(ovs_remote);
+    service_stop();
 
     exit(retval);
 }
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index d70ba39..554dba3 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1121,6 +1121,7 @@ main(int argc, char *argv[])
 
     fatal_ignore_sigpipe();
     set_program_name(argv[0]);
+    service_start(&argc, &argv);
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
     vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
     parse_options(argc, argv);
@@ -1311,11 +1312,15 @@ main(int argc, char *argv[])
             }
             poll_block();
         }
+        if (should_service_stop()) {
+            exiting = true;
+        }
     }
 
     unixctl_server_destroy(unixctl);
     ovsdb_idl_destroy(ovnsb_idl);
     ovsdb_idl_destroy(ovnnb_idl);
+    service_stop();
 
     exit(res);
 }
-- 
1.7.9.5




More information about the dev mailing list