pdu: Introduce iscsi_cancel_pdus()

Introduce a helper exported from lib/pdu.c which cancels all pdus for a
given context. This patch eliminates repeated code from various other
files which have the same purpose. The only functional difference is
that the cancellation done from iscsi-command.c was (incorrectly) not
checking for iscsi->is_loggedin before issuing callbacks.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
This commit is contained in:
Felipe Franciosi
2017-11-25 16:59:00 +00:00
parent 5aafc29991
commit 3c4925e8da
5 changed files with 33 additions and 65 deletions

View File

@@ -270,34 +270,11 @@ void iscsi_set_reconnect_max_retries(struct iscsi_context *iscsi, int count)
void iscsi_defer_reconnect(struct iscsi_context *iscsi)
{
struct iscsi_pdu *pdu;
iscsi->reconnect_deferred = 1;
ISCSI_LOG(iscsi, 2, "reconnect deferred, cancelling all tasks");
while ((pdu = iscsi->outqueue)) {
ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login,
we don't want to call any of the callbacks.
*/
pdu->callback(iscsi, SCSI_STATUS_CANCELLED,
NULL, pdu->private_data);
}
iscsi->drv->free_pdu(iscsi, pdu);
}
while ((pdu = iscsi->waitpdu)) {
ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
if (iscsi->is_loggedin && pdu->callback) {
/* If an error happened during connect/login,
we don't want to call any of the callbacks.
*/
pdu->callback(iscsi, SCSI_STATUS_CANCELLED,
NULL, pdu->private_data);
}
iscsi->drv->free_pdu(iscsi, pdu);
}
iscsi_cancel_pdus(iscsi);
}
void iscsi_reconnect_cb(struct iscsi_context *iscsi _U_, int status,