diff mbox series

[v1,2/3] example: traffic_mgmt add clean termination path

Message ID 1507827605-6030-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/3] linux-gen: odp_tm_stats_print should not depend on debug | expand

Commit Message

Github ODP bot Oct. 12, 2017, 5 p.m. UTC
From: Maxim Uvarov <maxim.uvarov@linaro.org>


example aborted on exit due to missing termination
path (exit terminated fd_server which signaled app
on the exit from main.)
https://bugs.linaro.org/show_bug.cgi?id=3024

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 229 (muvarov:master_bug3024)
 ** https://github.com/Linaro/odp/pull/229
 ** Patch: https://github.com/Linaro/odp/pull/229.patch
 ** Base sha: b529f843814f70068de2090e02df632113afa800
 ** Merge commit sha: b5f6031413a826cccfaa4468b62e2f3e90a12fff
 **/
 example/traffic_mgmt/odp_traffic_mgmt.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/example/traffic_mgmt/odp_traffic_mgmt.c b/example/traffic_mgmt/odp_traffic_mgmt.c
index c83b61522..1f1102ddf 100644
--- a/example/traffic_mgmt/odp_traffic_mgmt.c
+++ b/example/traffic_mgmt/odp_traffic_mgmt.c
@@ -766,12 +766,13 @@  int main(int argc, char *argv[])
 	rc = odp_init_global(&instance, &ODP_INIT_PARAMS, NULL);
 	if (rc != 0) {
 		printf("Error: odp_init_global() failed, rc = %d\n", rc);
-		abort();
+		return -1;
 	}
+
 	rc = odp_init_local(instance, ODP_THREAD_CONTROL);
 	if (rc != 0) {
 		printf("Error: odp_init_local() failed, rc = %d\n", rc);
-		abort();
+		return -1;
 	}
 
 	if (process_cmd_line_options(argc, argv) < 0)
@@ -793,5 +794,30 @@  int main(int argc, char *argv[])
 	       pkts_into_tm, pkts_from_tm);
 
 	odp_tm_stats_print(odp_tm_test);
+
+	rc = odp_pool_destroy(odp_pool);
+	if (rc != 0) {
+		printf("Error: odp_pool_destroy() failed, rc = %d\n", rc);
+		return -1;
+	}
+
+	rc = odp_tm_destroy(odp_tm_test);
+	if (rc != 0) {
+		printf("Error: odp_tm_destroy() failed, rc = %d\n", rc);
+		return -1;
+	}
+
+	rc = odp_term_local();
+	if (rc != 0) {
+		printf("Error: odp_term_local() failed, rc = %d\n", rc);
+		return -1;
+	}
+
+	/* Trying to keep this example as simple as possible we avoid
+	 * clean termination of TM queues. This will error on global
+	 * termination code
+	 */
+	(void)odp_term_global(instance);
+
 	return 0;
 }