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

Function queue_shutdown_close

examples/proxy.c:790–814  ·  view source on GitHub ↗

* Kill this socket - submit a shutdown and link a close to it. We don't * care about shutdown status, so mark it as not needing to post a CQE unless * it fails. */

Source from the content-addressed store, hash-verified

788 * it fails.
789 */
790static void queue_shutdown_close(struct io_uring *ring, struct conn *c, int fd)
791{
792 struct io_uring_sqe *sqe1, *sqe2;
793
794 /*
795 * On the off chance that we run out of SQEs after the first one,
796 * grab two upfront. This it to prevent our link not working if
797 * get_sqe() ends up doing submissions to free up an SQE, as links
798 * are not valid across separate submissions.
799 */
800 sqe1 = get_sqe(ring);
801 sqe2 = get_sqe(ring);
802
803 io_uring_prep_shutdown(sqe1, fd, SHUT_RDWR);
804 if (fixed_files)
805 sqe1->flags |= IOSQE_FIXED_FILE;
806 sqe1->flags |= IOSQE_IO_LINK | IOSQE_CQE_SKIP_SUCCESS;
807 encode_userdata(sqe1, c, __SHUTDOWN, 0, fd);
808
809 if (fixed_files)
810 io_uring_prep_close_direct(sqe2, fd);
811 else
812 io_uring_prep_close(sqe2, fd);
813 encode_userdata(sqe2, c, __CLOSE, 0, fd);
814}
815
816/*
817 * This connection is going away, queue a cancel for any pending recv, for

Callers 1

handle_cancelFunction · 0.85

Calls 2

get_sqeFunction · 0.70
encode_userdataFunction · 0.70

Tested by

no test coverage detected