From a1bbed818e9b18b82f312dc6fbefc8dbd1b6f992 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 17 Jan 2018 23:33:19 -0700 Subject: [PATCH] iscsi: flush PDUs immediately instead of waiting for poller Signed-off-by: Jim Harris Change-Id: I39152be9653316a24135cde497662cfbc8f68e3a Reviewed-on: https://review.gerrithub.io/395523 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Reviewed-by: Ben Walker Reviewed-by: Ziye Yang --- lib/iscsi/conn.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 117bf15270..938dfe4437 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1243,7 +1243,18 @@ spdk_iscsi_conn_flush_pdus(struct spdk_iscsi_conn *conn) void spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) { + int rc; + TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq); + rc = spdk_iscsi_conn_flush_pdus(conn); + if (rc < 0 && conn->state < ISCSI_CONN_STATE_EXITING) { + /* + * If the poller has already started destruction of the connection, + * i.e. the socket read failed, then the connection state may already + * be EXITED. We don't want to set it back to EXITING in that case. + */ + conn->state = ISCSI_CONN_STATE_EXITING; + } } #define GET_PDU_LOOP_COUNT 16