ecore_con_legacy: fix compatibility behavior (eos-mark on receiver done).
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 20 Dec 2016 12:12:59 +0000 (10:12 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 20 Dec 2016 12:18:33 +0000 (10:18 -0200)
While a socket can be closed to receive data resulting in EOS, it
could still be used to send stuff. Then it won't result in "finished",
just "read,finished" event.

However, previously this was considered a disconnect and we must
respect this otherwise tests (Ecore_Con_Eet suite) will hang waiting
for a disconnect.

src/lib/ecore_con/ecore_con_legacy.c

index 54b929dc53c6bc8e6a22e330c8fcc5f5c0bd4546..bfff6d939cd1f9da5a2a73461223894ead3ab3ae 100644 (file)
@@ -538,6 +538,17 @@ _ecore_con_client_socket_slice_changed(void *data, const Efl_Event *event EINA_U
    _ecore_con_post_event_client_data(cl, rw_slice);
 }
 
+static void
+_ecore_con_client_socket_read_finished(void *data, const Efl_Event *event EINA_UNUSED)
+{
+   Ecore_Con_Client *cl = data;
+
+   DBG("client %p socket %p read finished, queue EOS", cl, cl->socket);
+
+   if (!efl_io_closer_closed_get(cl->socket))
+     efl_io_buffered_stream_eos_mark(cl->socket);
+}
+
 static void
 _ecore_con_client_socket_finished(void *data, const Efl_Event *event EINA_UNUSED)
 {
@@ -567,6 +578,7 @@ _ecore_con_client_socket_error(void *data, const Efl_Event *event)
 EFL_CALLBACKS_ARRAY_DEFINE(_ecore_con_client_socket_cbs,
                            { EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, _ecore_con_client_socket_progress },
                            { EFL_IO_BUFFERED_STREAM_EVENT_SLICE_CHANGED, _ecore_con_client_socket_slice_changed },
+                           { EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED, _ecore_con_client_socket_read_finished },
                            { EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, _ecore_con_client_socket_finished },
                            { EFL_IO_BUFFERED_STREAM_EVENT_ERROR, _ecore_con_client_socket_error });
 
@@ -1238,6 +1250,17 @@ _ecore_con_server_dialer_progress(void *data, const Efl_Event *event EINA_UNUSED
    svr->pending_write = now;
 }
 
+static void
+_ecore_con_server_dialer_read_finished(void *data, const Efl_Event *event EINA_UNUSED)
+{
+   Ecore_Con_Server *svr = data;
+
+   if (svr->delete_me) return;
+
+   if (!efl_io_closer_closed_get(svr->dialer))
+     efl_io_buffered_stream_eos_mark(svr->dialer);
+}
+
 static void
 _ecore_con_server_dialer_finished(void *data, const Efl_Event *event EINA_UNUSED)
 {
@@ -1316,6 +1339,7 @@ _ecore_con_server_dialer_connected(void *data, const Efl_Event *event EINA_UNUSE
 EFL_CALLBACKS_ARRAY_DEFINE(_ecore_con_server_dialer_cbs,
                            { EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS, _ecore_con_server_dialer_progress },
                            { EFL_IO_BUFFERED_STREAM_EVENT_SLICE_CHANGED, _ecore_con_server_dialer_slice_changed },
+                           { EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED, _ecore_con_server_dialer_read_finished },
                            { EFL_IO_BUFFERED_STREAM_EVENT_FINISHED, _ecore_con_server_dialer_finished },
                            { EFL_NET_DIALER_EVENT_ERROR, _ecore_con_server_dialer_error },
                            { EFL_NET_DIALER_EVENT_RESOLVED, _ecore_con_server_dialer_resolved },