barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=bfe2988f4d5c9ed5b94022a6003fbc12fe47291a

commit bfe2988f4d5c9ed5b94022a6003fbc12fe47291a
Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi>
Date:   Mon Mar 27 10:53:43 2017 -0300

    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.
---
 src/examples/ecore/efl_net_dialer_unix_example.c | 24 +++++++++++++++---------
 1 file 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 57110ef..e890a3a 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
 _can_read(void *data EINA_UNUSED, const Efl_Event *event)
 {
    char buf[4];
-   Eina_Rw_Slice rw_slice = EINA_SLICE_ARRAY(buf);
    Eina_Error err;
    Eina_Bool can_read = efl_io_reader_can_read_get(event->object);
 
@@ -45,16 +44,23 @@ _can_read(void *data EINA_UNUSED, const Efl_Event *event)
    if (!can_read) return;
    if (!do_read) return;
 
-   err = efl_io_reader_read(event->object, &rw_slice);
-   if (err)
+   do
      {
-        fprintf(stderr, "ERROR: could not read: %s\n", 
eina_error_msg_get(err));
-        retval = EXIT_FAILURE;
-        ecore_main_loop_quit();
-        return;
+        Eina_Rw_Slice rw_slice = EINA_SLICE_ARRAY(buf);
+
+        err = efl_io_reader_read(event->object, &rw_slice);
+        if (err)
+          {
+             if (err == EAGAIN) return;
+             fprintf(stderr, "ERROR: could not read: %s\n", 
eina_error_msg_get(err));
+             retval = EXIT_FAILURE;
+             ecore_main_loop_quit();
+             return;
+          }
+
+        fprintf(stderr, "INFO: read '" EINA_SLICE_STR_FMT "'\n", 
EINA_SLICE_STR_PRINT(rw_slice));
      }
-
-   fprintf(stderr, "INFO: read '" EINA_SLICE_STR_FMT "'\n", 
EINA_SLICE_STR_PRINT(rw_slice));
+   while (efl_io_reader_can_read_get(event->object));
 }
 
 static void

-- 


Reply via email to