Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ioset_close(struct io_fd **fdp)
- {
- return ioset_shutdown(fdp, IOFD_SHUTDOWN);
- }
- int ioset_shutdown(struct io_fd **fdp, int mode)
- {
- int res;
- struct io_fd *fd = *fdp;
- struct ioq *send = &fd->send;
- *fdp = NULL;
- if (fd->close_cb)
- fd->close_cb(fd);
- if ((send->get != send->put) && (mode & IOFD_FLUSH)) {
- res = fcntl(fd->fd, F_GETFL);
- fcntl(fd->fd, F_SETFL, res&~O_NONBLOCK);
- ioset_flush_sendq(fd);
- if (send->get != send->put)
- ioset_flush_sendq(fd);
- }
- res = fd->fd;
- epoll_remove(fd);
- free(fd->send.buf);
- free(fd->recv.buf);
- free(fd);
- return (mode & IOFD_CLOSE) ? close(res) : res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement