Below is the list of changes that have just been committed into a local
5.2 repository of hezx. When hezx does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-28 14:41:42+08:00, hezx@hezx.(none) +4 -0
Use List instead of LIST for master_list
sql/slave.cc@stripped, 2007-06-28 14:38:04+08:00, hezx@hezx.(none) +16 -14
Use List instead of LIST for master_list
sql/slave.h@stripped, 2007-06-28 14:38:04+08:00, hezx@hezx.(none) +2 -5
Use List instead of LIST for master_list
sql/sql_list.h@stripped, 2007-06-28 14:38:06+08:00, hezx@hezx.(none) +0 -1
Use List instead of LIST for master_list
sql/sql_repl.cc@stripped, 2007-06-28 14:38:07+08:00, hezx@hezx.(none) +20 -22
Use List instead of LIST for master_list
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: hezx
# Host: hezx.(none)
# Root: /media/hda5/work/mysql/mysql-5.2
--- 1.309/sql/slave.cc 2007-06-28 14:42:54 +08:00
+++ 1.310/sql/slave.cc 2007-06-28 14:42:54 +08:00
@@ -52,7 +52,8 @@
/* multiple master */
#ifdef USE_MULTI_MASTER
//MASTER_INFO main_mi;
-LIST master_list;
+MEM_ROOT slave_mem_root;
+List<MASTER_INFO> master_list;
#endif
/*
@@ -194,10 +195,12 @@
/* Create the default master info structure */
- MASTER_INFO *mi = new MASTER_INFO;
+ MASTER_INFO *mi= new MASTER_INFO;
+ init_sql_alloc(&slave_mem_root, 1024, 0);
+
//mi->set_name("MAIN");
active_mi= mi;
- master_list.data = mi;
+ master_list.push_back(mi, &slave_mem_root);
init_one_master(mi);
@@ -232,7 +235,7 @@
break;
mi = new MASTER_INFO;
mi->set_name(name);
- list_cons_append(mi, &master_list);
+ master_list.push_back(mi, &slave_mem_root);
init_one_master(mi);
}
@@ -554,7 +557,7 @@
}
#ifdef USE_MULTI_MASTER
-static int end_slave_on_walk(MASTER_INFO* mi, gptr notused /*unused*/)
+static int end_slave_on_walk(MASTER_INFO* mi)
{
DBUG_ENTER("end_slave_on_walk");
@@ -573,7 +576,7 @@
*/
#ifdef USE_MULTI_MASTER
-static int end_slave_on_walk(MASTER_INFO* mi, gptr notused /*unused*/);
+static int end_slave_on_walk(MASTER_INFO* mi);
#endif
void end_slave()
@@ -590,19 +593,18 @@
pthread_mutex_lock(&LOCK_active_mi);
if (active_mi)
{
- /*
- TODO: replace the line below with
- list_walk(&master_list, (list_walk_action)end_slave_on_walk,0);
- once multi-master code is ready.
- */
#ifdef USE_MULTI_MASTER
- list_walk(&master_list, (list_walk_action)end_slave_on_walk, 0);
- // TODO: release all items in the master_list
+ while (!master_list.is_empty())
+ {
+ MASTER_INFO *mi= master_list.pop();
+ end_slave_on_walk(mi);
+ delete mi;
+ }
#else
terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
end_master_info(active_mi);
-#endif
delete active_mi;
+#endif
active_mi= 0;
}
pthread_mutex_unlock(&LOCK_active_mi);
--- 1.46/sql/sql_list.h 2007-06-28 14:42:54 +08:00
+++ 1.47/sql/sql_list.h 2007-06-28 14:42:54 +08:00
@@ -371,7 +371,6 @@
}
};
-
template <class T> class List_iterator :public base_list_iterator
{
public:
--- 1.107/sql/slave.h 2007-06-28 14:42:54 +08:00
+++ 1.108/sql/slave.h 2007-06-28 14:42:54 +08:00
@@ -206,15 +206,12 @@
pthread_handler_t handle_slave_sql(void *arg);
extern bool volatile abort_loop;
extern MASTER_INFO main_mi, *active_mi; /* active_mi for multi-master */
-extern LIST master_list;
extern my_bool replicate_same_server_id;
#ifdef USE_MULTI_MASTER
+extern MEM_ROOT slave_mem_root;
+extern List<MASTER_INFO> master_list;
#define MASTER_NAME_LEN 16
-/* typedef struct st_master { */
-/* char *name; */
-/* MASTER_INFO *mi; */
-/* } MASTER_ITEM; */
#endif
extern int disconnect_slave_event_count, abort_slave_event_count ;
--- 1.170/sql/sql_repl.cc 2007-06-28 14:42:54 +08:00
+++ 1.171/sql/sql_repl.cc 2007-06-28 14:42:54 +08:00
@@ -768,12 +768,12 @@
if (thd->lex->mi.all)
{
- LIST *list = &master_list;
-
- if (list_walk(list,
- (list_walk_action)slave_action,
- (char *)thd))
- goto err;
+ List_iterator<MASTER_INFO> iter(master_list);
+ while ((mi = iter++))
+ {
+ if (slave_action(mi, thd))
+ goto err;
+ }
}
else if (thd->lex->mi.master_list.is_empty())
{
@@ -1149,17 +1149,17 @@
MASTER_INFO *get_master_info(char *name)
{
if (!name || !name[0])
- return (MASTER_INFO *) master_list.data;
+ return master_list.head();
- LIST *list= master_list.next;
- while (list)
+ List_iterator<MASTER_INFO> iter(master_list);
+ MASTER_INFO *mi;
+ iter++; // get ride of the main master
+ while ((mi= iter++))
{
- MASTER_INFO *mi = (MASTER_INFO *)list->data;
if (!strcmp(name, mi->master_name))
{
return mi;
}
- list= list_rest(list);
}
return (MASTER_INFO *)NULL;
}
@@ -1206,7 +1206,7 @@
DBUG_RETURN(1);
}
- list_cons_append(mi, &master_list);
+ master_list.push_back(mi, &slave_mem_root);
send_ok(thd);
DBUG_RETURN(0);
}
@@ -1214,11 +1214,12 @@
bool drop_master(MASTER_INFO *mi, THD *thd)
{
int thread_mask= 0;
- LIST *element;
+ MASTER_INFO *m;
+ List_iterator<MASTER_INFO> element;
DBUG_ENTER("drop_master");
- if (mi == (MASTER_INFO *)master_list.data)
+ if (mi == master_list.head())
{
my_message(ER_MASTER_INFO, "Can not delete main master", MYF(0));
goto err;
@@ -1233,15 +1234,12 @@
}
/* FIXME: (HEZX) this is not elegant and efficient */
- element= master_list.next;
- while (element && (MASTER_INFO *)element->data != mi)
- {
- element= list_rest(element);
- }
- DBUG_ASSERT(element);
+ element.init(master_list);
+ while (element++ != mi)
+ ;
+
unlock_slave_threads(mi);
- list_delete(&master_list, element);
- delete mi;
+ element.remove(); // remove current node
DBUG_RETURN(FALSE);
err_locked:
unlock_slave_threads(mi);
| Thread |
|---|
| • bk commit into 5.2 tree (hezx:1.2509) | hezhenxing | 28 Jun |