Reconnect: If we are logged in and we experience a session failure, then

try to re-connect and redrive all I/O

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-05-01 18:45:28 +10:00
parent 256415e284
commit 9e5535adfd
5 changed files with 172 additions and 9 deletions

View File

@@ -410,6 +410,11 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
}
iscsi->socket_status_cb(iscsi, SCSI_STATUS_ERROR, NULL,
iscsi->connect_data);
if (iscsi->is_loggedin) {
if (iscsi_reconnect(iscsi) == 0) {
return 0;
}
}
return -1;
}
if (revents & POLLHUP) {
@@ -417,6 +422,11 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
"socket error.");
iscsi->socket_status_cb(iscsi, SCSI_STATUS_ERROR, NULL,
iscsi->connect_data);
if (iscsi->is_loggedin) {
if (iscsi_reconnect(iscsi) == 0) {
return 0;
}
}
return -1;
}
@@ -434,6 +444,11 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
strerror(err), err);
iscsi->socket_status_cb(iscsi, SCSI_STATUS_ERROR,
NULL, iscsi->connect_data);
if (iscsi->is_loggedin) {
if (iscsi_reconnect(iscsi) == 0) {
return 0;
}
}
return -1;
}
@@ -448,12 +463,23 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
if (revents & POLLOUT && iscsi->outqueue != NULL) {
if (iscsi_write_to_socket(iscsi) != 0) {
if (iscsi->is_loggedin) {
if (iscsi_reconnect(iscsi) == 0) {
return 0;
}
}
return -1;
}
}
if (revents & POLLIN) {
if (iscsi_read_from_socket(iscsi) != 0)
if (iscsi_read_from_socket(iscsi) != 0) {
if (iscsi->is_loggedin) {
if (iscsi_reconnect(iscsi) == 0) {
return 0;
}
}
return -1;
}
}
return 0;