summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-27 10:53:43 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-29 12:44:19 -0300
commitbfe2988f4d5c9ed5b94022a6003fbc12fe47291a (patch)
tree84ff1061dc0ac5e7fef4c08c9ca9282b19128fb8
parenteac53691f9429fc23462abba92cbd77b514e12bb (diff)
efl_net_dialer_unix_example: read in loop while "can_read".
While in UNIX we use 'select()/poll()' to query for read fds and this will eventually callback with "can_read" event, use the loop to match other implementations where can_read keeps true if not all data was read.
-rw-r--r--src/examples/ecore/efl_net_dialer_unix_example.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/examples/ecore/efl_net_dialer_unix_example.c b/src/examples/ecore/efl_net_dialer_unix_example.c
index 57110ef76e..e890a3a21f 100644
--- a/src/examples/ecore/efl_net_dialer_unix_example.c
+++ b/src/examples/ecore/efl_net_dialer_unix_example.c
@@ -33,7 +33,6 @@ static void
33_can_read(void *data EINA_UNUSED, const Efl_Event *event) 33_can_read(void *data EINA_UNUSED, const Efl_Event *event)
34{ 34{
35 char buf[4]; 35 char buf[4];
36 Eina_Rw_Slice rw_slice = EINA_SLICE_ARRAY(buf);
37 Eina_Error err; 36 Eina_Error err;
38 Eina_Bool can_read = efl_io_reader_can_read_get(event->object); 37 Eina_Bool can_read = efl_io_reader_can_read_get(event->object);
39 38
@@ -45,16 +44,23 @@ _can_read(void *data EINA_UNUSED, const Efl_Event *event)
45 if (!can_read) return; 44 if (!can_read) return;
46 if (!do_read) return; 45 if (!do_read) return;
47 46
48 err = efl_io_reader_read(event->object, &rw_slice); 47 do
49 if (err)
50 { 48 {
51 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err)); 49 Eina_Rw_Slice rw_slice = EINA_SLICE_ARRAY(buf);
52 retval = EXIT_FAILURE; 50
53 ecore_main_loop_quit(); 51 err = efl_io_reader_read(event->object, &rw_slice);
54 return; 52 if (err)
53 {
54 if (err == EAGAIN) return;
55 fprintf(stderr, "ERROR: could not read: %s\n", eina_error_msg_get(err));
56 retval = EXIT_FAILURE;
57 ecore_main_loop_quit();
58 return;
59 }
60
61 fprintf(stderr, "INFO: read '" EINA_SLICE_STR_FMT "'\n", EINA_SLICE_STR_PRINT(rw_slice));
55 } 62 }
56 63 while (efl_io_reader_can_read_get(event->object));
57 fprintf(stderr, "INFO: read '" EINA_SLICE_STR_FMT "'\n", EINA_SLICE_STR_PRINT(rw_slice));
58} 64}
59 65
60static void 66static void