uring: Add the sock into pending_recv list if there is data in pipe

Port the similiar code from posix sock module if a sock
is removed and added to a new group.

Change-Id: I306bed3c90f79ee06a363fbab02c776e756cda2f
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2047
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Ziye Yang 2020-04-28 04:58:39 +08:00 committed by Tomasz Zawadzki
parent 3bd113eae7
commit 339e42ffdf

View File

@ -1151,6 +1151,14 @@ spdk_uring_sock_group_impl_add_sock(struct spdk_sock_group_impl *_group,
sock->pollin_task.sock = sock;
sock->pollin_task.type = SPDK_SOCK_TASK_POLLIN;
/* switched from another polling group due to scheduling */
if (spdk_unlikely(sock->recv_pipe != NULL &&
(spdk_pipe_reader_bytes_available(sock->recv_pipe) > 0))) {
assert(sock->pending_recv == false);
sock->pending_recv = true;
TAILQ_INSERT_TAIL(&group->pending_recv, sock, link);
}
return 0;
}
@ -1161,6 +1169,7 @@ spdk_uring_sock_group_impl_remove_sock(struct spdk_sock_group_impl *_group,
struct spdk_uring_sock *sock = __uring_sock(_sock);
struct spdk_uring_sock_group_impl *group = __uring_group_impl(_group);
if (sock->write_task.status != SPDK_URING_SOCK_TASK_NOT_IN_USE) {
sock->outstanding_io++;
}
@ -1169,10 +1178,12 @@ spdk_uring_sock_group_impl_remove_sock(struct spdk_sock_group_impl *_group,
sock->outstanding_io++;
}
if ((sock->recv_pipe != NULL) &&
spdk_pipe_reader_bytes_available(sock->recv_pipe) > 0) {
TAILQ_REMOVE(&group->pending_recv, sock, link);
sock->pending_recv = false;
if (sock->recv_pipe != NULL) {
if (spdk_pipe_reader_bytes_available(sock->recv_pipe) > 0) {
TAILQ_REMOVE(&group->pending_recv, sock, link);
sock->pending_recv = false;
}
assert(sock->pending_recv == false);
}
if (!sock->outstanding_io) {