spdk: do not half-close the connection before reading the response - #77
Merged
artek-koltun merged 1 commit intoJul 10, 2026
Conversation
artek-koltun
approved these changes
Jul 10, 2026
artek-koltun
left a comment
Contributor
There was a problem hiding this comment.
Good, we probably need this first: #76
tfrankow-intel
force-pushed
the
fix/jsonrpc-avoid-write-half-close
branch
from
July 10, 2026 09:18
578e5de to
4bde8c9
Compare
Client.communicate() called conn.CloseWrite() immediately after writing
the request and before reading the reply, half-closing the write side
of the socket.
SPDK's JSON-RPC server marks conn->closed when it sees the client's
write-half EOF. Historically that was harmless because
jsonrpc_server_send_response queued the reply regardless. SPDK commit
274643bf27f2d8ac04d8326e90c17c62cd31a614 ("lib/jsonrpc: fix memory leak
on closed connection") changed that: send_response now checks
conn->closed and, when set, drops the reply instead of queuing it,
logging "attempt to send response on closed connection".
For asynchronous RPCs whose reply is produced later by a poller
(e.g. nvmf_create_transport, bdev_nvme_attach_controller), the client's
half-close is processed before the reply is ready, so with that change
the server drops the reply and the client reads a spurious EOF even
though the operation succeeded on the target.
A JSON-RPC request is self-delimiting (a single complete JSON object),
so half-closing the write side is unnecessary to frame the request.
Remove the CloseWrite and keep the connection fully open until the
single response is read.
Signed-off-by: Frankowski, Tomasz <tomasz.frankowski@intel.com>
tfrankow-intel
force-pushed
the
fix/jsonrpc-avoid-write-half-close
branch
from
July 10, 2026 12:05
4bde8c9 to
9663d8a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client.communicate() called conn.CloseWrite() immediately after writing the request and before reading the reply, half-closing the write side of the socket.
SPDK's JSON-RPC server marks conn->closed when it sees the client's write-half EOF. Historically that was harmless because jsonrpc_server_send_response queued the reply regardless. SPDK commit 274643bf27f2d8ac04d8326e90c17c62cd31a614 ("lib/jsonrpc: fix memory leak on closed connection") changed that: send_response now checks conn->closed and, when set, drops the reply instead of queuing it, logging "attempt to send response on closed connection".
For asynchronous RPCs whose reply is produced later by a poller (e.g. nvmf_create_transport, bdev_nvme_attach_controller), the client's half-close is processed before the reply is ready, so with that change the server drops the reply and the client reads a spurious EOF even though the operation succeeded on the target.
A JSON-RPC request is self-delimiting (a single complete JSON object), so half-closing the write side is unnecessary to frame the request. Remove the CloseWrite and keep the connection fully open until the single response is read.