diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index dc265c431..3339fe7df 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1393,30 +1393,6 @@ spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p iscsi_conn_flush_pdus(conn); } -#define GET_PDU_LOOP_COUNT 16 - -static int -iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn) -{ - int i, rc; - - /* Read new PDUs from network */ - for (i = 0; i < GET_PDU_LOOP_COUNT; i++) { - rc = spdk_iscsi_read_pdu(conn); - if (rc == 0) { - break; - } else if (rc < 0) { - return rc; - } - - if (conn->is_stopped) { - break; - } - } - - return i; -} - static void iscsi_conn_sock_cb(void *arg, struct spdk_sock_group *group, struct spdk_sock *sock) { @@ -1431,7 +1407,7 @@ iscsi_conn_sock_cb(void *arg, struct spdk_sock_group *group, struct spdk_sock *s } /* Handle incoming PDUs */ - rc = iscsi_conn_handle_incoming_pdus(conn); + rc = spdk_iscsi_handle_incoming_pdus(conn); if (rc < 0) { conn->state = ISCSI_CONN_STATE_EXITING; } diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index e2e3acee3..4e8c50223 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4586,8 +4586,8 @@ iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) return rc; } -int -spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn) +static int +iscsi_read_pdu(struct spdk_iscsi_conn *conn) { enum iscsi_pdu_recv_state prev_state; struct spdk_iscsi_pdu *pdu; @@ -4780,6 +4780,30 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn) return 0; } +#define GET_PDU_LOOP_COUNT 16 + +int +spdk_iscsi_handle_incoming_pdus(struct spdk_iscsi_conn *conn) +{ + int i, rc; + + /* Read new PDUs from network */ + for (i = 0; i < GET_PDU_LOOP_COUNT; i++) { + rc = iscsi_read_pdu(conn); + if (rc == 0) { + break; + } else if (rc < 0) { + return rc; + } + + if (conn->is_stopped) { + break; + } + } + + return i; +} + bool spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, struct spdk_dif_ctx *dif_ctx) diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index 62203e61f..7de2ddb0a 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -412,7 +412,7 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task); int spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovcnt, struct spdk_iscsi_pdu *pdu, uint32_t *mapped_length); -int spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn); +int spdk_iscsi_handle_incoming_pdus(struct spdk_iscsi_conn *conn); bool spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, struct spdk_dif_ctx *dif_ctx); void spdk_iscsi_task_mgmt_response(struct spdk_iscsi_conn *conn, diff --git a/test/unit/lib/iscsi/conn.c/conn_ut.c b/test/unit/lib/iscsi/conn.c/conn_ut.c index 31fca067a..fc0705371 100644 --- a/test/unit/lib/iscsi/conn.c/conn_ut.c +++ b/test/unit/lib/iscsi/conn.c/conn_ut.c @@ -148,7 +148,7 @@ DEFINE_STUB_V(spdk_del_transfer_task, DEFINE_STUB(spdk_iscsi_conn_handle_queued_datain_tasks, int, (struct spdk_iscsi_conn *conn), 0); -DEFINE_STUB(spdk_iscsi_read_pdu, int, (struct spdk_iscsi_conn *conn), 0); +DEFINE_STUB(spdk_iscsi_handle_incoming_pdus, int, (struct spdk_iscsi_conn *conn), 0); DEFINE_STUB_V(spdk_free_sess, (struct spdk_iscsi_sess *sess));