ecore: remove use of efl_main_loop_get from efl_net_server_simple_example.
This commit is contained in:
parent
c72683d04d
commit
e624e7344a
|
@ -1,11 +1,7 @@
|
||||||
#define EFL_BETA_API_SUPPORT 1
|
#include <Efl_Net.h>
|
||||||
#define EFL_EO_API_SUPPORT 1
|
|
||||||
#include <Ecore.h>
|
|
||||||
#include <Ecore_Con.h>
|
|
||||||
#include <Ecore_Getopt.h>
|
#include <Ecore_Getopt.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
static int retval = EXIT_SUCCESS;
|
|
||||||
static Eina_Bool echo = EINA_FALSE;
|
static Eina_Bool echo = EINA_FALSE;
|
||||||
static double timeout = 10.0;
|
static double timeout = 10.0;
|
||||||
|
|
||||||
|
@ -124,7 +120,7 @@ _echo_copier_error(void *data EINA_UNUSED, const Efl_Event *event)
|
||||||
return;
|
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",
|
fprintf(stderr, "ERROR: echo copier %p failed %d '%s', close and del.\n",
|
||||||
copier, *perr, eina_error_msg_get(*perr));
|
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;
|
const Eina_Error *perr = event->info;
|
||||||
fprintf(stderr, "ERROR: %d '%s'\n", *perr, eina_error_msg_get(*perr));
|
fprintf(stderr, "ERROR: %d '%s'\n", *perr, eina_error_msg_get(*perr));
|
||||||
retval = EXIT_FAILURE;
|
efl_loop_quit(efl_loop_get(event->object), eina_value_int_init(EXIT_FAILURE));
|
||||||
ecore_main_loop_quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -340,8 +335,39 @@ static const Ecore_Getopt options = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
static Eo *simple_server = NULL;
|
||||||
main(int argc, char **argv)
|
|
||||||
|
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;
|
const Efl_Class *cls;
|
||||||
char *protocol = NULL;
|
char *protocol = NULL;
|
||||||
|
@ -395,34 +421,28 @@ main(int argc, char **argv)
|
||||||
ECORE_GETOPT_VALUE_NONE /* sentinel */
|
ECORE_GETOPT_VALUE_NONE /* sentinel */
|
||||||
};
|
};
|
||||||
int args;
|
int args;
|
||||||
Eo *simple_server, *server;
|
Eo *server;
|
||||||
Eina_Error err;
|
Eina_Error err;
|
||||||
|
|
||||||
ecore_init();
|
args = ecore_getopt_parse(&options, values, 0, NULL);
|
||||||
ecore_con_init();
|
|
||||||
|
|
||||||
args = ecore_getopt_parse(&options, values, argc, argv);
|
|
||||||
if (args < 0)
|
if (args < 0)
|
||||||
{
|
{
|
||||||
fputs("ERROR: Could not parse command line options.\n", stderr);
|
fputs("ERROR: Could not parse command line options.\n", stderr);
|
||||||
retval = EXIT_FAILURE;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quit_option) 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)
|
if (args < 0)
|
||||||
{
|
{
|
||||||
fputs("ERROR: Could not parse positional arguments.\n", stderr);
|
fputs("ERROR: Could not parse positional arguments.\n", stderr);
|
||||||
retval = EXIT_FAILURE;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!protocol)
|
if (!protocol)
|
||||||
{
|
{
|
||||||
fputs("ERROR: missing protocol.\n", stderr);
|
fputs("ERROR: missing protocol.\n", stderr);
|
||||||
retval = EXIT_FAILURE;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +461,7 @@ main(int argc, char **argv)
|
||||||
goto end;
|
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_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,
|
efl_net_server_clients_limit_set(efl_added,
|
||||||
clients_limit,
|
clients_limit,
|
||||||
|
@ -540,7 +560,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_main_loop_begin();
|
return ;
|
||||||
|
|
||||||
end_server:
|
end_server:
|
||||||
efl_del(simple_server);
|
efl_del(simple_server);
|
||||||
|
@ -549,8 +569,8 @@ main(int argc, char **argv)
|
||||||
end:
|
end:
|
||||||
EINA_LIST_FREE(udp_mcast_groups, str)
|
EINA_LIST_FREE(udp_mcast_groups, str)
|
||||||
free(str);
|
free(str);
|
||||||
ecore_con_shutdown();
|
|
||||||
ecore_shutdown();
|
|
||||||
|
|
||||||
return retval;
|
efl_loop_quit(ev->object, eina_value_int_init(EXIT_FAILURE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFL_MAIN_EX();
|
||||||
|
|
Loading…
Reference in New Issue