sock/posix: Block recursive calls to spdk_sock_flush

Don't allow calling spdk_sock_flush while the socket is
closed.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483148 (master)
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>

(cherry picked from commit d0f4a51fdc)
Change-Id: I9020a49ab8906b0f343e3f48f8b96bd38308ab17
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483380
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ben Walker 2020-01-28 13:16:40 -07:00 committed by Tomasz Zawadzki
parent 06e7d22c06
commit 7c06ec7247
2 changed files with 13 additions and 0 deletions

View File

@ -236,6 +236,11 @@ nvme_tcp_ctrlr_disconnect_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_
struct nvme_tcp_qpair *tqpair = nvme_tcp_qpair(qpair);
struct nvme_tcp_pdu *pdu;
if (nvme_qpair_get_state(qpair) == NVME_QPAIR_DISABLED) {
/* Already disconnecting */
return;
}
nvme_qpair_set_state(qpair, NVME_QPAIR_DISABLED);
spdk_sock_close(&tqpair->sock);

View File

@ -332,6 +332,14 @@ spdk_sock_writev_async(struct spdk_sock *sock, struct spdk_sock_request *req)
int
spdk_sock_flush(struct spdk_sock *sock)
{
if (sock == NULL) {
return -EBADF;
}
if (sock->flags.closed) {
return -EBADF;
}
return sock->net_impl->flush(sock);
}