40 #include <sys/socket.h>
90 if (__sync_sub_and_fetch(&io->
ref_count, 1))
102 struct io *
io = user_data;
130 struct io *
io = user_data;
134 if ((events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR))) {
152 io->
events &= ~EPOLLRDHUP;
204 io =
new0(
struct io, 1);
283 if (!io || io->
fd < 0)
290 events = io->
events | EPOLLIN;
292 events = io->
events & ~EPOLLIN;
322 if (!io || io->
fd < 0)
329 events = io->
events | EPOLLOUT;
331 events = io->
events & ~EPOLLOUT;
361 if (!io || io->
fd < 0)
368 events = io->
events | EPOLLRDHUP;
370 events = io->
events & ~EPOLLRDHUP;
395 ssize_t
io_send(
struct io *
io,
const struct iovec *iov,
int iovcnt)
399 if (!io || io->
fd < 0)
403 ret = writev(io->
fd, iov, iovcnt);
404 }
while (ret < 0 && errno == EINTR);
419 if (!io || io->
fd < 0)
422 return shutdown(io->
fd, SHUT_RDWR) == 0;
bool io_set_write_handler(struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
static struct io * io_ref(struct io *io)
struct io * io_new(int fd)
data structure to manage io
ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt)
io_destroy_func_t write_destroy
bool io_set_close_on_destroy(struct io *io, bool do_close)
io_callback_func_t write_callback
static void io_cleanup(void *user_data)
int mainloop_add_fd(int fd, uint32_t events, mainloop_event_func callback, void *user_data, mainloop_destroy_func destroy)
int mainloop_remove_fd(int fd)
bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
static void io_callback(int fd, uint32_t events, void *user_data)
void io_destroy(struct io *io)
void(* io_destroy_func_t)(void *data)
int mainloop_modify_fd(int fd, uint32_t events)
io_destroy_func_t read_destroy
bool io_set_read_handler(struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
int io_get_fd(struct io *io)
io_callback_func_t read_callback
static void io_unref(struct io *io)
bool io_shutdown(struct io *io)
bool(* io_callback_func_t)(struct io *io, void *user_data)
io_destroy_func_t disconnect_destroy
io_callback_func_t disconnect_callback