MCPcopy Create free account
hub / github.com/axboe/liburing / handle_shutdown

Function handle_shutdown

examples/proxy.c:1745–1765  ·  view source on GitHub ↗

* We don't expect to get here, as we marked it with skipping posting a * CQE if it was successful. If it does trigger, than means it fails and * that our close has not been done. Log the shutdown error and issue a new * separate close. */

Source from the content-addressed store, hash-verified

1743 * separate close.
1744 */
1745static int handle_shutdown(struct io_uring *ring, struct io_uring_cqe *cqe)
1746{
1747 struct conn *c = cqe_to_conn(cqe);
1748 struct io_uring_sqe *sqe;
1749 int fd = cqe_to_fd(cqe);
1750
1751 fprintf(stderr, "Got shutdown notification on fd %d\n", fd);
1752
1753 if (!cqe->res)
1754 fprintf(stderr, "Unexpected success shutdown CQE\n");
1755 else if (cqe->res < 0)
1756 fprintf(stderr, "Shutdown got %s\n", strerror(-cqe->res));
1757
1758 sqe = get_sqe(ring);
1759 if (fixed_files)
1760 io_uring_prep_close_direct(sqe, fd);
1761 else
1762 io_uring_prep_close(sqe, fd);
1763 encode_userdata(sqe, c, __CLOSE, 0, fd);
1764 return 0;
1765}
1766
1767/*
1768 * Final stage of a connection, the shutdown and close has finished. Mark

Callers 1

handle_cqeFunction · 0.85

Calls 4

cqe_to_connFunction · 0.85
cqe_to_fdFunction · 0.85
get_sqeFunction · 0.70
encode_userdataFunction · 0.70

Tested by

no test coverage detected