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.
This commit is contained in:
Gustavo Sverzut Barbieri 2016-11-25 01:24:38 -02:00
parent a9d9936a08
commit c534d79124
2 changed files with 16 additions and 0 deletions

View File

@ -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)
{

View File

@ -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;