fdm: rename struct fd -> struct handler

This commit is contained in:
Daniel Eklöf 2019-11-02 23:37:19 +01:00
parent 9b67a6627a
commit 8ffa021de8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

22
fdm.c
View file

@ -12,18 +12,18 @@
#include "log.h" #include "log.h"
#include "tllist.h" #include "tllist.h"
struct fd { struct handler {
int fd; int fd;
void *data; fdm_handler_t callback;
fdm_handler_t handler; void *callback_data;
bool deleted; bool deleted;
}; };
struct fdm { struct fdm {
int epoll_fd; int epoll_fd;
bool is_polling; bool is_polling;
tll(struct fd *) fds; tll(struct handler *) fds;
tll(struct fd *) deferred_delete; tll(struct handler *) deferred_delete;
}; };
struct fdm * struct fdm *
@ -75,11 +75,11 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
} }
#endif #endif
struct fd *fd_data = malloc(sizeof(*fd_data)); struct handler *fd_data = malloc(sizeof(*fd_data));
*fd_data = (struct fd) { *fd_data = (struct handler) {
.fd = fd, .fd = fd,
.data = data, .callback = handler,
.handler = handler, .callback_data = data,
.deleted = false, .deleted = false,
}; };
@ -165,11 +165,11 @@ fdm_poll(struct fdm *fdm)
fdm->is_polling = true; fdm->is_polling = true;
for (int i = 0; i < ret; i++) { for (int i = 0; i < ret; i++) {
struct fd *fd = events[i].data.ptr; struct handler *fd = events[i].data.ptr;
if (fd->deleted) if (fd->deleted)
continue; continue;
if (!fd->handler(fdm, fd->fd, events[i].events, fd->data)) { if (!fd->callback(fdm, fd->fd, events[i].events, fd->callback_data)) {
ret = false; ret = false;
break; break;
} }