sync: cancel pending pdus on error

The set of sync connect calls use a stack variable to track the
connection status. This is ok because such calls block on event_poll()
until the connection is established. However, event_poll may return
early in case of errors (or timeout) while PDUs are still queued on the
context (and pointing to a local stack).

This cancels any pending PDUs before returning from sync connect calls.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
This commit is contained in:
Felipe Franciosi
2017-11-25 17:12:38 +00:00
parent 3c4925e8da
commit 25eb87c7ee

View File

@@ -114,6 +114,11 @@ iscsi_connect_sync(struct iscsi_context *iscsi, const char *portal)
/* clear connect_data so it doesnt point to our stack */
iscsi->connect_data = NULL;
/* in case of error, cancel any pending pdus */
if (state.status != SCSI_STATUS_GOOD) {
iscsi_cancel_pdus(iscsi);
}
return (state.status == SCSI_STATUS_GOOD) ? 0 : -1;
}
@@ -135,9 +140,9 @@ iscsi_full_connect_sync(struct iscsi_context *iscsi,
event_loop(iscsi, &state);
/* in case of error, clear loggedin flag to prevent pending pdu callbacks */
if (state.status != 0) {
iscsi->is_loggedin = 0;
/* in case of error, cancel any pending pdus */
if (state.status != SCSI_STATUS_GOOD) {
iscsi_cancel_pdus(iscsi);
}
return (state.status == SCSI_STATUS_GOOD) ? 0 : -1;