summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 01:24:38 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 17:25:18 -0200
commitc534d7912434d0d0fdc6adf1941f0bddac640dd7 (patch)
treefe59e935461b726f98b4914d5320a3662f3ca922
parenta9d9936a088d8033de2b468d131589b635fc3205 (diff)
downloadefl-c534d7912434d0d0fdc6adf1941f0bddac640dd7.tar.gz
efl_net_socket_fd: stop monitoring fd on EOS.
There was a bug that if the remote peer closed the connection, it would trigger 'read' event, which would read 0 bytes, flagging as EOS... but then marking as "can_read", which was wrong. Just stop monitoring the events and fix that.
-rw-r--r--src/lib/ecore_con/efl_net_socket_fd.c15
-rw-r--r--src/lib/ecore_con/efl_net_socket_fd.eo1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/ecore_con/efl_net_socket_fd.c b/src/lib/ecore_con/efl_net_socket_fd.c
index 822154cbb3..e2ddcc222b 100644
--- a/src/lib/ecore_con/efl_net_socket_fd.c
+++ b/src/lib/ecore_con/efl_net_socket_fd.c
@@ -238,6 +238,21 @@ _efl_net_socket_fd_efl_io_reader_can_read_set(Eo *o, Efl_Net_Socket_Fd_Data *pd
}
}
+EOLIAN static void
+_efl_net_socket_fd_efl_io_reader_eos_set(Eo *o, Efl_Net_Socket_Fd_Data *pd EINA_UNUSED, Eina_Bool value)
+{
+ Eina_Bool old = efl_io_reader_eos_get(o);
+ if (old == value) return;
+
+ efl_io_reader_eos_set(efl_super(o, MY_CLASS), value);
+
+ if (!value) return;
+
+ /* stop monitoring the FD, it's closed */
+ efl_event_callback_del(o, EFL_LOOP_FD_EVENT_READ, _efl_net_socket_fd_event_read, NULL);
+ efl_event_callback_del(o, EFL_LOOP_FD_EVENT_WRITE, _efl_net_socket_fd_event_write, NULL);
+}
+
EOLIAN static Eina_Error
_efl_net_socket_fd_efl_io_writer_write(Eo *o, Efl_Net_Socket_Fd_Data *pd EINA_UNUSED, Eina_Slice *ro_slice, Eina_Slice *remaining)
{
diff --git a/src/lib/ecore_con/efl_net_socket_fd.eo b/src/lib/ecore_con/efl_net_socket_fd.eo
index b5973f9578..8250800eec 100644
--- a/src/lib/ecore_con/efl_net_socket_fd.eo
+++ b/src/lib/ecore_con/efl_net_socket_fd.eo
@@ -38,6 +38,7 @@ class Efl.Net.Socket.Fd (Efl.Loop.Fd, Efl.Io.Reader.Fd, Efl.Io.Writer.Fd, Efl.Io
Efl.Io.Closer.closed.get;
Efl.Io.Reader.read;
Efl.Io.Reader.can_read.set;
+ Efl.Io.Reader.eos.set;
Efl.Io.Writer.write;
Efl.Io.Writer.can_write.set;
Efl.Net.Socket.address_local;