Diff between 22ee00198a6cb9bb7277ebc8a244763e7f4d1430 and 1876483852eae481acd1e060131d011519200ddf

Changed Files

File Additions Deletions Status
plugins/mgmtops.c +21 -1 modified

Full Patch

diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index ff5ee3e..e9c6f0b 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -76,6 +76,8 @@ static struct controller_info {
 	gboolean pending_class;
 	uint8_t major;
 	uint8_t minor;
+
+	gboolean pending_powered;
 } *controllers = NULL;
 
 static int mgmt_sock = -1;
@@ -953,7 +955,20 @@ static void read_index_list_complete(int sk, void *buf, size_t len)
 
 static int mgmt_set_powered(int index, gboolean powered)
 {
-	DBG("index %d powered %d", index, powered);
+	struct controller_info *info = &controllers[index];
+
+	DBG("index %d powered %d pending_uuid %u", index, powered,
+							info->pending_uuid);
+
+	if (powered) {
+		if (info->pending_uuid) {
+			info->pending_powered = TRUE;
+			return 0;
+		}
+	} else {
+		info->pending_powered = FALSE;
+	}
+
 	return mgmt_set_mode(index, MGMT_OP_SET_POWERED, powered);
 }
 
@@ -1242,6 +1257,11 @@ static void mgmt_add_uuid_complete(int sk, uint16_t index, void *buf,
 			mgmt_set_dev_class(index, info->major, info->minor);
 		}
 
+		if (info->pending_powered) {
+			info->pending_powered = FALSE;
+			mgmt_set_powered(index, 1);
+		}
+
 		return;
 	}