#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void handler_poll(struct pollfd *fds, controller_t *controller, MDB_env *mdb_env) { /* An event on one of the fds has occurred. */ for(int i = 0; i < POLL_FDS_COUNT; i++) { if(fds[i].revents & POLLIN) { /* data may be read on device number i. */ LOG_DEBUG("fd %i may read data\n", fds[i].fd); switch(i) { case POLL_FDS_DISCOVERY: handler_discovery(fds[i].fd, controller); break; case POLL_FDS_COMMAND: handler_command(fds[i].fd, controller); controller_save(controller, mdb_env); break; } } if(fds[i].revents & POLLHUP) { /* A hangup has occurred on device number i. */ LOG_DEBUG("fd %i got closed\n", fds[i].fd); } } }