| 681 | } |
| 682 | |
| 683 | static void __submit_receive(struct io_uring *ring, struct conn *c, |
| 684 | struct conn_dir *cd, int fd) |
| 685 | { |
| 686 | struct conn_buf_ring *cbr = &c->in_br; |
| 687 | struct io_uring_sqe *sqe; |
| 688 | |
| 689 | vlog("%d: submit receive fd=%d\n", c->tid, fd); |
| 690 | |
| 691 | assert(!cd->pending_recv); |
| 692 | cd->pending_recv = 1; |
| 693 | |
| 694 | /* |
| 695 | * For both recv and multishot receive, we use the ring provided |
| 696 | * buffers. These are handed to the application ahead of time, and |
| 697 | * are consumed when a receive triggers. Note that the address and |
| 698 | * length of the receive are set to NULL/0, and we assign the |
| 699 | * sqe->buf_group to tell the kernel which buffer group ID to pick |
| 700 | * a buffer from. Finally, IOSQE_BUFFER_SELECT is set to tell the |
| 701 | * kernel that we want a buffer picked for this request, we are not |
| 702 | * passing one in with the request. |
| 703 | */ |
| 704 | sqe = get_sqe(ring); |
| 705 | if (rcv_msg) { |
| 706 | struct io_msg *imsg = &cd->io_rcv_msg; |
| 707 | struct msghdr *msg = &imsg->msg; |
| 708 | |
| 709 | memset(msg, 0, sizeof(*msg)); |
| 710 | msg->msg_iov = msg_vec(imsg)->iov; |
| 711 | msg->msg_iovlen = msg_vec(imsg)->iov_len; |
| 712 | |
| 713 | if (recv_mshot) { |
| 714 | cd->rcv_mshot++; |
| 715 | io_uring_prep_recvmsg_multishot(sqe, fd, &imsg->msg, 0); |
| 716 | } else { |
| 717 | io_uring_prep_recvmsg(sqe, fd, &imsg->msg, 0); |
| 718 | } |
| 719 | } else { |
| 720 | if (recv_mshot) { |
| 721 | cd->rcv_mshot++; |
| 722 | io_uring_prep_recv_multishot(sqe, fd, NULL, 0, 0); |
| 723 | } else { |
| 724 | io_uring_prep_recv(sqe, fd, NULL, 0, 0); |
| 725 | } |
| 726 | } |
| 727 | encode_userdata(sqe, c, __RECV, 0, fd); |
| 728 | sqe->buf_group = cbr->bgid; |
| 729 | sqe->flags |= IOSQE_BUFFER_SELECT; |
| 730 | if (fixed_files) |
| 731 | sqe->flags |= IOSQE_FIXED_FILE; |
| 732 | if (rcv_bundle) |
| 733 | sqe->ioprio |= IORING_RECVSEND_BUNDLE; |
| 734 | } |
| 735 | |
| 736 | /* |
| 737 | * One directional just arms receive on our in_fd |
no test coverage detected