Blob Blame History Raw
reconnect: do not initialize iscsi to old_iscsi, use old_iscsi if appropriate

Message-id: <1383729402-27559-6-git-send-email-pbonzini@redhat.com>
Patchwork-id: 55500
O-Subject: [PATCH 05/11] reconnect: do not initialize iscsi to old_iscsi, use old_iscsi if appropriate
Bugzilla: 1026820
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

Makes it clearer that logging has to be done on the existing context,
since the "iscsi" pointer will not survive iscsi_reconnect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit c3e8d0c9454835074ebcc6971618b2e71bb948c4)

Conflicts:
	lib/connect.c
---
 lib/connect.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/connect.c b/lib/connect.c
index 0d4c957..d6a8759 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -217,22 +217,22 @@ void iscsi_defer_reconnect(struct iscsi_context *iscsi)
 
 int iscsi_reconnect(struct iscsi_context *old_iscsi)
 {
-	struct iscsi_context *iscsi = old_iscsi;
+	struct iscsi_context *iscsi;
 
 	/* if there is already a deferred reconnect do not try again */
-	if (iscsi->reconnect_deferred) {
-		ISCSI_LOG(iscsi, 2, "reconnect initiated, but reconnect is already deferred");
+	if (old_iscsi->reconnect_deferred) {
+		ISCSI_LOG(old_iscsi, 2, "reconnect initiated, but reconnect is already deferred");
 		return -1;
 	}
 
-	ISCSI_LOG(iscsi, 2, "reconnect initiated");
+	ISCSI_LOG(old_iscsi, 2, "reconnect initiated");
 
 	/* This is mainly for tests, where we do not want to automatically
 	   reconnect but rather want the commands to fail with an error
 	   if the target drops the session.
 	 */
-	if (iscsi->no_auto_reconnect) {
-		iscsi_defer_reconnect(iscsi);
+	if (old_iscsi->no_auto_reconnect) {
+		iscsi_defer_reconnect(old_iscsi);
 		return 0;
 	}
 
@@ -288,7 +288,7 @@ try_again:
 		if (backoff > 30) {
 			backoff=30;
 		}
-		ISCSI_LOG(iscsi, 1, "reconnect try %d failed, waiting %d seconds",retry,backoff);
+		ISCSI_LOG(old_iscsi, 1, "reconnect try %d failed, waiting %d seconds", retry, backoff);
 		iscsi_destroy_context(iscsi);
 		sleep(backoff);
 		retry++;
@@ -356,11 +356,11 @@ try_again:
 	iscsi->mallocs+=old_iscsi->mallocs;
 	iscsi->frees+=old_iscsi->frees;
 
-	ISCSI_LOG(iscsi, 2, "reconnect was successful");
-
 	memcpy(old_iscsi, iscsi, sizeof(struct iscsi_context));
 	free(iscsi);
 
+	ISCSI_LOG(old_iscsi, 2, "reconnect was successful");
+
 	old_iscsi->is_reconnecting = 0;
 	old_iscsi->last_reconnect = time(NULL);