From afc2343e471598a8c7b4bcf95230952f121b6226 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Wed, 10 Jan 2018 11:23:52 -0800 Subject: [PATCH] ecore: remove use of efl_main_loop_get from efl_net_server_simple_example. --- src/examples/ecore/efl_net_server_simple_example.c | 68 ++++++++++++++-------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/examples/ecore/efl_net_server_simple_example.c b/src/examples/ecore/efl_net_server_simple_example.c index c5d889e..93ad6ba 100644 --- a/src/examples/ecore/efl_net_server_simple_example.c +++ b/src/examples/ecore/efl_net_server_simple_example.c @@ -1,11 +1,7 @@ -#define EFL_BETA_API_SUPPORT 1 -#define EFL_EO_API_SUPPORT 1 -#include -#include +#include #include #include -static int retval = EXIT_SUCCESS; static Eina_Bool echo = EINA_FALSE; static double timeout = 10.0; @@ -124,7 +120,7 @@ _echo_copier_error(void *data EINA_UNUSED, const Efl_Event *event) return; } - retval = EXIT_FAILURE; + efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE)); fprintf(stderr, "ERROR: echo copier %p failed %d '%s', close and del.\n", copier, *perr, eina_error_msg_get(*perr)); @@ -214,8 +210,7 @@ _server_error(void *data EINA_UNUSED, const Efl_Event *event) { const Eina_Error *perr = event->info; fprintf(stderr, "ERROR: %d '%s'\n", *perr, eina_error_msg_get(*perr)); - retval = EXIT_FAILURE; - ecore_main_loop_quit(); + efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE)); } static void @@ -340,8 +335,39 @@ static const Ecore_Getopt options = { } }; -int -main(int argc, char **argv) +static Eo *simple_server = NULL; + +EAPI_MAIN void +efl_pause(void *data EINA_UNUSED, + const Efl_Event *ev EINA_UNUSED) +{ +} + +EAPI_MAIN void +efl_resume(void *data EINA_UNUSED, + const Efl_Event *ev EINA_UNUSED) +{ +} + +EAPI_MAIN void +efl_terminate(void *data EINA_UNUSED, + const Efl_Event *ev EINA_UNUSED) +{ + /* FIXME: For the moment the main loop doesn't get + properly destroyed on shutdown which disallow + relying on parent destroying their children */ + if (simple_server) + { + efl_del(simple_server); + simple_server = NULL; + } + + fprintf(stderr, "INFO: main loop finished.\n"); +} + +EAPI_MAIN void +efl_main(void *data EINA_UNUSED, + const Efl_Event *ev) { const Efl_Class *cls; char *protocol = NULL; @@ -395,34 +421,28 @@ main(int argc, char **argv) ECORE_GETOPT_VALUE_NONE /* sentinel */ }; int args; - Eo *simple_server, *server; + Eo *server; Eina_Error err; - ecore_init(); - ecore_con_init(); - - args = ecore_getopt_parse(&options, values, argc, argv); + args = ecore_getopt_parse(&options, values, 0, NULL); if (args < 0) { fputs("ERROR: Could not parse command line options.\n", stderr); - retval = EXIT_FAILURE; goto end; } if (quit_option) goto end; - args = ecore_getopt_parse_positional(&options, values, argc, argv, args); + args = ecore_getopt_parse_positional(&options, values, 0, NULL, args); if (args < 0) { fputs("ERROR: Could not parse positional arguments.\n", stderr); - retval = EXIT_FAILURE; goto end; } if (!protocol) { fputs("ERROR: missing protocol.\n", stderr); - retval = EXIT_FAILURE; goto end; } @@ -441,7 +461,7 @@ main(int argc, char **argv) goto end; } - simple_server = efl_add(EFL_NET_SERVER_SIMPLE_CLASS, efl_main_loop_get(), /* it's mandatory to use a main loop provider as the server parent */ + simple_server = efl_add(EFL_NET_SERVER_SIMPLE_CLASS, ev->object, /* it's mandatory to use a main loop provider as the server parent */ efl_net_server_simple_inner_class_set(efl_added, cls), /* alternatively you could create the inner server and set with efl_net_server_simple_inner_server_set() */ efl_net_server_clients_limit_set(efl_added, clients_limit, @@ -540,7 +560,7 @@ main(int argc, char **argv) } } - ecore_main_loop_begin(); + return ; end_server: efl_del(simple_server); @@ -549,8 +569,8 @@ main(int argc, char **argv) end: EINA_LIST_FREE(udp_mcast_groups, str) free(str); - ecore_con_shutdown(); - ecore_shutdown(); - return retval; + efl_loop_quit(ev->object, eina_value_int_init(EXIT_FAILURE)); } + +EFL_MAIN_EX(); -- 2.7.4