jsonrpc: move closed conn handling before poll()
Make sure that we check any closed connections even if poll() indicates that no sockets are ready, since closed sockets won't ever trigger poll(). Change-Id: Ie543cc2848d07f3d8e22662cb22c3d0f5cf3d174 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/369292 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7f6b78611a
commit
122e284652
@ -325,6 +325,37 @@ spdk_jsonrpc_server_poll(struct spdk_jsonrpc_server *server)
|
||||
struct pollfd *pfd;
|
||||
struct spdk_jsonrpc_server_conn *conn;
|
||||
|
||||
for (i = 0; i < server->num_conns; i++) {
|
||||
conn = &server->conns[i];
|
||||
|
||||
if (conn->closed) {
|
||||
struct spdk_jsonrpc_request *request;
|
||||
|
||||
/*
|
||||
* The client closed the connection, but there may still be requests
|
||||
* outstanding; we have no way to cancel outstanding requests, so wait until
|
||||
* each outstanding request sends a response (which will be discarded, since
|
||||
* the connection is closed).
|
||||
*/
|
||||
|
||||
if (conn->send_request) {
|
||||
spdk_jsonrpc_free_request(conn->send_request);
|
||||
conn->send_request = NULL;
|
||||
}
|
||||
|
||||
while (spdk_ring_dequeue(conn->send_queue, (void **)&request, 1) == 1) {
|
||||
spdk_jsonrpc_free_request(request);
|
||||
}
|
||||
|
||||
if (conn->outstanding_requests == 0) {
|
||||
SPDK_TRACELOG(SPDK_TRACE_RPC, "all outstanding requests completed\n");
|
||||
spdk_jsonrpc_server_conn_remove(conn);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
rc = poll(server->pollfds, server->num_conns + 1, 0);
|
||||
|
||||
if (rc < 0) {
|
||||
@ -354,33 +385,6 @@ spdk_jsonrpc_server_poll(struct spdk_jsonrpc_server *server)
|
||||
pfd = &server->pollfds[i + 1];
|
||||
conn = &server->conns[i];
|
||||
|
||||
if (conn->closed) {
|
||||
struct spdk_jsonrpc_request *request;
|
||||
|
||||
/*
|
||||
* The client closed the connection, but there may still be requests
|
||||
* outstanding; we have no way to cancel outstanding requests, so wait until
|
||||
* each outstanding request sends a response (which will be discarded, since
|
||||
* the connection is closed).
|
||||
*/
|
||||
|
||||
if (conn->send_request) {
|
||||
spdk_jsonrpc_free_request(conn->send_request);
|
||||
conn->send_request = NULL;
|
||||
}
|
||||
|
||||
while (spdk_ring_dequeue(conn->send_queue, (void **)&request, 1) == 1) {
|
||||
spdk_jsonrpc_free_request(request);
|
||||
}
|
||||
|
||||
if (conn->outstanding_requests == 0) {
|
||||
SPDK_TRACELOG(SPDK_TRACE_RPC, "all outstanding requests completed\n");
|
||||
spdk_jsonrpc_server_conn_remove(conn);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pfd->revents & POLLOUT) {
|
||||
rc = spdk_jsonrpc_server_conn_send(conn);
|
||||
if (rc != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user