forked from enlightenment/efl
ecore - fix fd handlers to also set read/write/err flags on hup's
odd - i found ecore fd handlers basically ignored hangups from the other end so we never knew if the other end went or not... crazy. now we at least have all the read/write/error flags on and the next read should fail indicating the broken pipe etc. ... @fix
This commit is contained in:
parent
8555a22972
commit
468b2b380c
|
@ -215,7 +215,7 @@ static gboolean ecore_fds_ready;
|
|||
static inline void
|
||||
_ecore_fd_valid(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED)
|
||||
{
|
||||
# ifdef HAVE_EPOLL
|
||||
# ifdef HAVE_SYS_EPOLL_H
|
||||
if ((pd->epoll_fd >= 0) &&
|
||||
(fcntl(pd->epoll_fd, F_GETFD) < 0))
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ _throttle_do(Efl_Loop_Data *pd)
|
|||
eina_evlog("-throttle", NULL, 0.0, NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
static inline int
|
||||
_ecore_get_epoll_fd(Eo *obj, Efl_Loop_Data *pd)
|
||||
{
|
||||
|
@ -289,9 +289,9 @@ static inline int
|
|||
_ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh)
|
||||
{
|
||||
int events = 0;
|
||||
if (fdh->flags & ECORE_FD_READ) events |= EPOLLIN;
|
||||
if (fdh->flags & ECORE_FD_WRITE) events |= EPOLLOUT;
|
||||
if (fdh->flags & ECORE_FD_ERROR) events |= EPOLLERR | EPOLLPRI;
|
||||
if (fdh->flags & ECORE_FD_READ) events |= EPOLLIN | EPOLLHUP;
|
||||
if (fdh->flags & ECORE_FD_WRITE) events |= EPOLLOUT | EPOLLHUP;
|
||||
if (fdh->flags & ECORE_FD_ERROR) events |= EPOLLERR | EPOLLPRI | EPOLLHUP;
|
||||
return events;
|
||||
}
|
||||
#endif
|
||||
|
@ -301,9 +301,9 @@ static inline int
|
|||
_gfd_events_from_fdh(Ecore_Fd_Handler *fdh)
|
||||
{
|
||||
int events = 0;
|
||||
if (fdh->flags & ECORE_FD_READ) events |= G_IO_IN;
|
||||
if (fdh->flags & ECORE_FD_WRITE) events |= G_IO_OUT;
|
||||
if (fdh->flags & ECORE_FD_ERROR) events |= G_IO_ERR;
|
||||
if (fdh->flags & ECORE_FD_READ) events |= G_IO_IN | G_IO_HUP;
|
||||
if (fdh->flags & ECORE_FD_WRITE) events |= G_IO_OUT | G_IO_HUP;
|
||||
if (fdh->flags & ECORE_FD_ERROR) events |= G_IO_ERR | G_IO_HUP;
|
||||
return events;
|
||||
}
|
||||
#endif
|
||||
|
@ -331,6 +331,12 @@ _ecore_main_uv_poll_cb(uv_poll_t *handle, int status, int events)
|
|||
if (events & UV_READABLE) fdh->read_active = EINA_TRUE;
|
||||
if (events & UV_WRITABLE) fdh->write_active = EINA_TRUE;
|
||||
|
||||
if (events & UV_DISCONNECT)
|
||||
{
|
||||
fdh->read_active = EINA_TRUE;
|
||||
fdh->write_active = EINA_TRUE;
|
||||
fdh->error_active = EINA_TRUE;
|
||||
}
|
||||
_ecore_try_add_to_call_list(obj, pd, fdh);
|
||||
|
||||
_ecore_main_fd_handlers_call(obj, pd);
|
||||
|
@ -358,7 +364,7 @@ _ecore_main_fdh_poll_add(Efl_Loop_Data *pd EINA_UNUSED, Ecore_Fd_Handler *fdh)
|
|||
DBG("_ecore_main_fdh_poll_add");
|
||||
int r = 0;
|
||||
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
# ifdef HAVE_LIBUV
|
||||
if (!_dl_uv_run)
|
||||
# endif
|
||||
|
@ -413,7 +419,7 @@ _ecore_main_fdh_poll_add(Efl_Loop_Data *pd EINA_UNUSED, Ecore_Fd_Handler *fdh)
|
|||
static inline void
|
||||
_ecore_main_fdh_poll_del(Efl_Loop_Data *pd, Ecore_Fd_Handler *fdh)
|
||||
{
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
# ifdef HAVE_LIBUV
|
||||
if (!_dl_uv_run)
|
||||
# endif
|
||||
|
@ -465,7 +471,7 @@ _ecore_main_fdh_poll_modify(Efl_Loop_Data *pd EINA_UNUSED, Ecore_Fd_Handler *fdh
|
|||
{
|
||||
DBG("_ecore_main_fdh_poll_modify %p", fdh);
|
||||
int r = 0;
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
# ifdef HAVE_LIBUV
|
||||
if (!_dl_uv_run)
|
||||
# endif
|
||||
|
@ -517,7 +523,7 @@ _ecore_main_idler_all_call(Eo *loop)
|
|||
eina_freeq_reduce(eina_freeq_main_get(), 84);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
static inline int
|
||||
_ecore_main_fdh_epoll_mark_active(Eo *obj, Efl_Loop_Data *pd)
|
||||
{
|
||||
|
@ -556,6 +562,13 @@ _ecore_main_fdh_epoll_mark_active(Eo *obj, Efl_Loop_Data *pd)
|
|||
if (ev[i].events & EPOLLOUT) fdh->write_active = EINA_TRUE;
|
||||
if (ev[i].events & EPOLLERR) fdh->error_active = EINA_TRUE;
|
||||
|
||||
if (ev[i].events & EPOLLHUP)
|
||||
{
|
||||
fdh->read_active = EINA_TRUE;
|
||||
fdh->write_active = EINA_TRUE;
|
||||
fdh->error_active = EINA_TRUE;
|
||||
}
|
||||
|
||||
_ecore_try_add_to_call_list(obj, pd, fdh);
|
||||
}
|
||||
return ret;
|
||||
|
@ -578,6 +591,13 @@ _ecore_main_fdh_glib_mark_active(Eo *obj, Efl_Loop_Data *pd)
|
|||
if (fdh->gfd.revents & G_IO_OUT) fdh->write_active = EINA_TRUE;
|
||||
if (fdh->gfd.revents & G_IO_ERR) fdh->error_active = EINA_TRUE;
|
||||
|
||||
if (fdh->gfd.revents & G_IO_HUP)
|
||||
{
|
||||
fdh->read_active = EINA_TRUE;
|
||||
fdh->write_active = EINA_TRUE;
|
||||
fdh->error_active = EINA_TRUE;
|
||||
}
|
||||
|
||||
_ecore_try_add_to_call_list(obj, fdh);
|
||||
|
||||
if (fdh->gfd.revents & (G_IO_IN | G_IO_OUT | G_IO_ERR)) ret++;
|
||||
|
@ -710,7 +730,7 @@ _ecore_main_gsource_check(GSource *source EINA_UNUSED)
|
|||
else ret = TRUE;
|
||||
|
||||
// check if fds are ready
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
if (pd->epoll_fd >= 0)
|
||||
ecore_fds_ready = (_ecore_main_fdh_epoll_mark_active(obj, pd) > 0);
|
||||
else
|
||||
|
@ -871,7 +891,7 @@ _ecore_main_loop_setup(Eo *obj, Efl_Loop_Data *pd)
|
|||
{
|
||||
// Please note that this function is being also called in case of a bad
|
||||
// fd to reset the main loop.
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
pd->epoll_fd = epoll_create(1);
|
||||
if (pd->epoll_fd < 0) WRN("Failed to create epoll fd!");
|
||||
else
|
||||
|
@ -974,7 +994,7 @@ _ecore_main_loop_setup(Eo *obj, Efl_Loop_Data *pd)
|
|||
{
|
||||
g_source_set_priority(ecore_glib_source,
|
||||
G_PRIORITY_HIGH_IDLE + 20);
|
||||
# ifdef HAVE_EPOLL
|
||||
# ifdef HAVE_SYS_EPOLL_H
|
||||
if (pd->epoll_fd >= 0)
|
||||
{
|
||||
// epoll multiplexes fds into the g_main_loop
|
||||
|
@ -1030,7 +1050,7 @@ _ecore_main_loop_clear(Eo *obj, Efl_Loop_Data *pd)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
# ifdef HAVE_EPOLL
|
||||
# ifdef HAVE_SYS_EPOLL_H
|
||||
if (pd->epoll_fd >= 0)
|
||||
{
|
||||
close(pd->epoll_fd);
|
||||
|
@ -1726,7 +1746,7 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double timeout)
|
|||
// call the prepare callback for all handlers
|
||||
if (pd->fd_handlers_with_prep) _ecore_main_prepare_handlers(obj, pd);
|
||||
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
if (pd->epoll_fd < 0)
|
||||
{
|
||||
#endif
|
||||
|
@ -1751,8 +1771,8 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double timeout)
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
}
|
||||
#ifdef HAVE_EPOLL
|
||||
else
|
||||
{
|
||||
// polling on the epoll fd will wake when fd in the epoll set is active
|
||||
|
@ -1806,7 +1826,7 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double timeout)
|
|||
}
|
||||
if (ret > 0)
|
||||
{
|
||||
#ifdef HAVE_EPOLL
|
||||
#ifdef HAVE_SYS_EPOLL_H
|
||||
if (pd->epoll_fd >= 0)
|
||||
_ecore_main_fdh_epoll_mark_active(obj, pd);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue