List:Commits« Previous MessageNext Message »
From:Sven Sandberg Date:October 20 2010 1:47pm
Subject:bzr commit into mysql-next-mr.crash-safe branch (sven.sandberg:3071) WL#5582
View as plain text  
#At file:///home/sven/bzr/w5393-rpl_locks/next-mr.crash-safe/ based on revid:sven.sandberg@stripped

 3071 Sven Sandberg	2010-10-20
      WL#5582: encapsulate replication locks
      This is a step to change functions that operate on RLI and MI structures
      to member functions, so that we can encapsulate things.
        
      In this commit, we change the global function start_slave_thread
      to a member function of Rpl_info. The new function is called
      Rpl_info::start.

    modified:
      sql/rpl_info.h
      sql/rpl_slave.cc
=== modified file 'sql/rpl_info.h'
--- a/sql/rpl_info.h	2010-10-19 17:52:22 +0000
+++ b/sql/rpl_info.h	2010-10-20 13:46:52 +0000
@@ -98,6 +98,15 @@ public:
   virtual bool is_killed() = 0;
   void run(THD **thd);
   virtual void do_run() = 0;
+  int start(
+#ifdef HAVE_PSI_INTERFACE
+            PSI_thread_key thread_key,
+#endif
+            mysql_mutex_t *start_lock,
+            mysql_mutex_t *cond_lock,
+            mysql_cond_t *start_cond,
+            volatile uint *slave_running,
+            volatile ulong *slave_run_id);
 
 protected:
   Rpl_info_handler *handler;

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-10-19 18:21:15 +0000
+++ b/sql/rpl_slave.cc	2010-10-20 13:46:52 +0000
@@ -783,20 +783,19 @@ terminate_slave_thread(THD *thd,
 }
 
 
-int start_slave_thread(
+int Rpl_info::start(
 #ifdef HAVE_PSI_INTERFACE
                        PSI_thread_key thread_key,
 #endif
-                       pthread_handler h_func, mysql_mutex_t *start_lock,
+                       mysql_mutex_t *start_lock,
                        mysql_mutex_t *cond_lock,
                        mysql_cond_t *start_cond,
                        volatile uint *slave_running,
-                       volatile ulong *slave_run_id,
-                       Rpl_info *info)
+                       volatile ulong *slave_run_id)
 {
   pthread_t th;
   ulong start_id;
-  DBUG_ENTER("start_slave_thread");
+  DBUG_ENTER("Rpl_info::start");
 
   if (start_lock)
     mysql_mutex_lock(start_lock);
@@ -821,7 +820,8 @@ int start_slave_thread(
   start_id= *slave_run_id;
   DBUG_PRINT("info",("Creating new slave thread"));
   if (mysql_thread_create(thread_key,
-                          &th, &connection_attrib, h_func, (void*)info))
+                          &th, &connection_attrib,
+                          handle_slave_thread, (void*)this))
   {
     if (start_lock)
       mysql_mutex_unlock(start_lock);
@@ -883,24 +883,20 @@ int start_slave_threads(bool need_slave_
   }
 
   if (thread_mask & SLAVE_IO)
-    error= start_slave_thread(
+    error= mi->start(
 #ifdef HAVE_PSI_INTERFACE
                               key_thread_slave_io,
 #endif
-                              handle_slave_thread, lock_io, lock_cond_io,
-                              cond_io,
-                              &mi->slave_running, &mi->slave_run_id,
-                              mi);
+                              lock_io, lock_cond_io, cond_io,
+                              &mi->slave_running, &mi->slave_run_id);
   if (!error && (thread_mask & SLAVE_SQL))
   {
-    error= start_slave_thread(
+    error= mi->rli->start(
 #ifdef HAVE_PSI_INTERFACE
                               key_thread_slave_sql,
 #endif
-                              handle_slave_thread, lock_sql, lock_cond_sql,
-                              cond_sql,
-                              &mi->rli->slave_running, &mi->rli->slave_run_id,
-                              mi->rli);
+                              lock_sql, lock_cond_sql, cond_sql,
+                              &mi->rli->slave_running, &mi->rli->slave_run_id);
     if (error)
       terminate_slave_threads(mi, thread_mask & SLAVE_IO, !need_slave_mutex);
   }


Attachment: [text/bzr-bundle] bzr/sven.sandberg@oracle.com-20101020134652-bu5h89e4sw8er2lj.bundle
Thread
bzr commit into mysql-next-mr.crash-safe branch (sven.sandberg:3071) WL#5582Sven Sandberg20 Oct