* Final stage of a connection, the shutdown and close has finished. Mark * it as disconnected and let the main loop reap it. */
| 1769 | * it as disconnected and let the main loop reap it. |
| 1770 | */ |
| 1771 | static int handle_close(struct io_uring *ring, struct io_uring_cqe *cqe) |
| 1772 | { |
| 1773 | struct conn *c = cqe_to_conn(cqe); |
| 1774 | int fd = cqe_to_fd(cqe); |
| 1775 | |
| 1776 | printf("Closed client: id=%d, in_fd=%d, out_fd=%d\n", c->tid, c->in_fd, c->out_fd); |
| 1777 | if (fd == c->in_fd) |
| 1778 | c->in_fd = -1; |
| 1779 | else if (fd == c->out_fd) |
| 1780 | c->out_fd = -1; |
| 1781 | |
| 1782 | if (c->in_fd == -1 && c->out_fd == -1) { |
| 1783 | c->flags |= CONN_F_DISCONNECTED; |
| 1784 | |
| 1785 | pthread_mutex_lock(&thread_lock); |
| 1786 | __show_stats(c); |
| 1787 | open_conns--; |
| 1788 | pthread_mutex_unlock(&thread_lock); |
| 1789 | free_buffer_rings(ring, c); |
| 1790 | free_msgs(&c->cd[0]); |
| 1791 | free_msgs(&c->cd[1]); |
| 1792 | free(c->cd[0].rcv_bucket); |
| 1793 | free(c->cd[0].snd_bucket); |
| 1794 | free(c->cd[1].rcv_bucket); |
| 1795 | free(c->cd[1].snd_bucket); |
| 1796 | } |
| 1797 | |
| 1798 | return 0; |
| 1799 | } |
| 1800 | |
| 1801 | static int handle_cancel(struct io_uring *ring, struct io_uring_cqe *cqe) |
| 1802 | { |
no test coverage detected