Commit 5fd1f68b authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

sock/posix: Add MSG_NOSIGNAL to prevent SIGPIPE for a socket that may be closed



We try avoiding write a closed socket by checking if the return value
of recv() is zero. However it is not possible to completely avoid writing
a socket which is already closed by the target.

Repeatedly adding/removing listener in the NVMe-oF TCP target caused
SIGPIPE to the NVMe-oF initiator.

Fix the issue by adding MSG_NOSIGINAL to the flag of sendmsg().

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I273679c91c4b867792e966b1dc2121f6d2188f16
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12119


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 75209b1d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -730,11 +730,11 @@ _sock_flush(struct spdk_sock *sock)
	msg.msg_iovlen = iovcnt;
#ifdef SPDK_ZEROCOPY
	if (psock->zcopy) {
		flags = MSG_ZEROCOPY;
		flags = MSG_ZEROCOPY | MSG_NOSIGNAL;
	} else
#endif
	{
		flags = 0;
		flags = MSG_NOSIGNAL;
	}
	rc = sendmsg(psock->fd, &msg, flags);
	if (rc <= 0) {