Browse Source

list: Unify the list processing with qb_list func

Signed-off-by: Takeshi MIZUTA <miz.take4@gmail.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Takeshi MIZUTA 9 years ago
parent
commit
f5dcc4a5f2
3 changed files with 11 additions and 14 deletions
  1. 9 8
      cts/agents/cpg_test_agent.c
  2. 1 1
      exec/totempg.c
  3. 1 5
      exec/votequorum.c

+ 9 - 8
cts/agents/cpg_test_agent.c

@@ -277,13 +277,12 @@ static void record_config_events (int sock)
 static void read_config_event (int sock)
 {
 	const char *empty = "None";
-	struct qb_list_head * list = config_chg_log_head.next;
 	log_entry_t *entry;
 	ssize_t rc;
 	size_t send_len;
 
-	if (list != &config_chg_log_head) {
-		entry = qb_list_entry (list, log_entry_t, list);
+	if (qb_list_empty(&config_chg_log_head) == 0) {
+		entry = qb_list_first_entry (&config_chg_log_head, log_entry_t, list);
 		send_len = strlen (entry->log);
 		rc = send (sock, entry->log, send_len, 0);
 		qb_list_del (&entry->list);
@@ -298,7 +297,8 @@ static void read_config_event (int sock)
 
 static void read_messages (int sock, char* atmost_str)
 {
-	struct qb_list_head * list;
+	struct qb_list_head *iter, *tmp_iter;
+
 	log_entry_t *entry;
 	int atmost = atoi (atmost_str);
 	int packed = 0;
@@ -311,15 +311,16 @@ static void read_messages (int sock, char* atmost_str)
 
 	big_and_buf[0] = '\0';
 
-	for (list = msg_log_head.next;
-		(!qb_list_empty (&msg_log_head) && packed < atmost); ) {
+	qb_list_for_each_safe(iter, tmp_iter, &msg_log_head) {
+
+		if (packed >= atmost)
+			break;
 
-		entry = qb_list_entry (list, log_entry_t, list);
+		entry = qb_list_entry (iter, log_entry_t, list);
 
 		strcat (big_and_buf, entry->log);
 		packed++;
 
-		list = list->next;
 		qb_list_del (&entry->list);
 		free (entry);
 

+ 1 - 1
exec/totempg.c

@@ -315,7 +315,7 @@ static struct assembly *assembly_ref (unsigned int nodeid)
 	 * Nothing found in inuse list get one from free list if available
 	 */
 	if (qb_list_empty (&assembly_list_free) == 0) {
-		assembly = qb_list_entry (assembly_list_free.next, struct assembly, list);
+		assembly = qb_list_first_entry (&assembly_list_free, struct assembly, list);
 		qb_list_del (&assembly->list);
 		qb_list_add (&assembly->list, active_assembly_list_inuse);
 		assembly->nodeid = nodeid;

+ 1 - 5
exec/votequorum.c

@@ -435,7 +435,6 @@ static void node_add_ordered(struct cluster_node *newnode)
 {
 	struct cluster_node *node = NULL;
 	struct qb_list_head *tmp;
-	struct qb_list_head *newlist = &newnode->list;
 
 	ENTER();
 
@@ -449,10 +448,7 @@ static void node_add_ordered(struct cluster_node *newnode)
 	if (!node) {
 		qb_list_add(&newnode->list, &cluster_members_list);
 	} else {
-		newlist->prev = tmp->prev;
-		newlist->next = tmp;
-		tmp->prev->next = newlist;
-		tmp->prev = newlist;
+		qb_list_add_tail(&newnode->list, &node->list);
 	}
 
 	LEAVE();