Diff between 164d6bf347f7b7bdd719244ca392ab5a1431330e and 41240a36a2e5ac62912dee8bcaad0d92aa1a0e17

Changed Files

File Additions Deletions Status
src/shared/mgmt.c +14 -0 modified
src/shared/mgmt.h +2 -0 modified

Full Patch

diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
index 6330c6f..e576990 100644
--- a/src/shared/mgmt.c
+++ b/src/shared/mgmt.c
@@ -45,6 +45,7 @@ struct mgmt {
 	bool close_on_unref;
 	struct io *io;
 	bool writer_active;
+	bool sync_write;
 	struct queue *request_queue;
 	struct queue *reply_queue;
 	struct queue *pending_list;
@@ -210,6 +211,8 @@ static bool can_write_data(struct io *io, void *user_data)
 
 static void wakeup_writer(struct mgmt *mgmt)
 {
+	while (mgmt->sync_write && can_write_data(mgmt->io, mgmt));
+
 	if (!queue_isempty(mgmt->pending_list)) {
 		/* only queued reply commands trigger wakeup */
 		if (queue_isempty(mgmt->reply_queue))
@@ -461,6 +464,7 @@ struct mgmt *mgmt_new(int fd)
 	}
 
 	mgmt->writer_active = false;
+	mgmt->sync_write = false;
 
 	return mgmt_ref(mgmt);
 }
@@ -575,6 +579,16 @@ bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close)
 	return true;
 }
 
+bool mgmt_set_sync_write(struct mgmt *mgmt, bool sync_write)
+{
+	if (!mgmt)
+		return false;
+
+	mgmt->sync_write = sync_write;
+
+	return true;
+}
+
 static struct mgmt_request *create_request(uint16_t opcode, uint16_t index,
 				uint16_t length, const void *param,
 				mgmt_request_func_t callback,
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 626a699..49c8c99 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -43,6 +43,8 @@ bool mgmt_set_debug(struct mgmt *mgmt, mgmt_debug_func_t callback,
 
 bool mgmt_set_close_on_unref(struct mgmt *mgmt, bool do_close);
 
+bool mgmt_set_sync_write(struct mgmt *mgmt, bool sync_write);
+
 typedef void (*mgmt_request_func_t)(uint8_t status, uint16_t length,
 					const void *param, void *user_data);