uloop: Add flag to allow callback to be called on error conditions.

In some conditions, an application is interested in errors happening
on a file descriptor and might be able to resolve the issue in the
callback function.

This patch adds a flag to notify the uloop framework that errors
should be passed to the callback function, instead of silently
removing the fd from the polling set.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
This commit is contained in:
Karl Vogel 2014-02-11 09:37:08 +01:00 committed by Felix Fietkau
parent 43d2d349cb
commit 926121113b
2 changed files with 6 additions and 2 deletions

View file

@ -174,7 +174,8 @@ static int uloop_fetch_events(int timeout)
if (events[n].flags & EV_ERROR) { if (events[n].flags & EV_ERROR) {
u->error = true; u->error = true;
uloop_fd_delete(u); if (!(u->flags & ULOOP_ERROR_CB))
uloop_fd_delete(u);
} }
if(events[n].filter == EVFILT_READ) if(events[n].filter == EVFILT_READ)
@ -268,7 +269,8 @@ static int uloop_fetch_events(int timeout)
if (events[n].events & (EPOLLERR|EPOLLHUP)) { if (events[n].events & (EPOLLERR|EPOLLHUP)) {
u->error = true; u->error = true;
uloop_fd_delete(u); if (!(u->flags & ULOOP_ERROR_CB))
uloop_fd_delete(u);
} }
if(!(events[n].events & (EPOLLRDHUP|EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP))) { if(!(events[n].events & (EPOLLRDHUP|EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP))) {

View file

@ -53,6 +53,8 @@ typedef void (*uloop_process_handler)(struct uloop_process *c, int ret);
#define ULOOP_EDGE_DEFER (1 << 5) #define ULOOP_EDGE_DEFER (1 << 5)
#endif #endif
#define ULOOP_ERROR_CB (1 << 6)
struct uloop_fd struct uloop_fd
{ {
uloop_fd_handler cb; uloop_fd_handler cb;