[Groonga-mysql-commit] mroonga/mroonga at 5236779 [master] Add lock for mrn_long_term_share related operations

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jun 11 16:37:25 JST 2013


Kouhei Sutou	2013-06-11 16:37:25 +0900 (Tue, 11 Jun 2013)

  New Revision: 5236779438299c3029f0a93c57463d4a3c19ba23
  https://github.com/mroonga/mroonga/commit/5236779438299c3029f0a93c57463d4a3c19ba23

  Message:
    Add lock for mrn_long_term_share related operations

  Modified files:
    ha_mroonga.cpp
    mrn_table.cpp

  Modified: ha_mroonga.cpp (+7 -0)
===================================================================
--- ha_mroonga.cpp    2013-06-11 16:32:02 +0900 (83bbc1b)
+++ ha_mroonga.cpp    2013-06-11 16:37:25 +0900 (5dd933a)
@@ -147,6 +147,7 @@ handlerton *mrn_hton_ptr;
 HASH mrn_open_tables;
 pthread_mutex_t mrn_open_tables_mutex;
 HASH mrn_long_term_share;
+pthread_mutex_t mrn_long_term_share_mutex;
 
 /* internal variables */
 static grn_ctx mrn_ctx;
@@ -1779,6 +1780,9 @@ static int mrn_init(void *p)
                    mrn_open_tables_get_key, 0, 0)) {
     goto error_allocated_open_tables_hash_init;
   }
+  if ((pthread_mutex_init(&mrn_long_term_share_mutex, NULL) != 0)) {
+    goto error_allocated_long_term_share_mutex_init;
+  }
   if (my_hash_init(&mrn_long_term_share, system_charset_info, 32, 0, 0,
                    mrn_long_term_share_get_key, 0, 0)) {
     goto error_allocated_long_term_share_hash_init;
@@ -1787,6 +1791,8 @@ static int mrn_init(void *p)
   return 0;
 
 error_allocated_long_term_share_hash_init:
+  pthread_mutex_destroy(&mrn_long_term_share_mutex);
+error_allocated_long_term_share_mutex_init:
   my_hash_free(&mrn_open_tables);
 error_allocated_open_tables_hash_init:
   pthread_mutex_destroy(&mrn_open_tables_mutex);
@@ -1846,6 +1852,7 @@ static int mrn_deinit(void *p)
   }
 
   my_hash_free(&mrn_long_term_share);
+  pthread_mutex_destroy(&mrn_long_term_share_mutex);
   my_hash_free(&mrn_open_tables);
   pthread_mutex_destroy(&mrn_open_tables_mutex);
   my_hash_free(&mrn_allocated_thds);

  Modified: mrn_table.cpp (+5 -0)
===================================================================
--- mrn_table.cpp    2013-06-11 16:32:02 +0900 (9da6270)
+++ mrn_table.cpp    2013-06-11 16:37:25 +0900 (0e272be)
@@ -53,6 +53,7 @@ extern "C" {
 extern HASH mrn_open_tables;
 extern pthread_mutex_t mrn_open_tables_mutex;
 extern HASH mrn_long_term_share;
+extern pthread_mutex_t mrn_long_term_share_mutex;
 extern char *mrn_default_parser;
 extern char *mrn_default_wrapper_engine;
 extern handlerton *mrn_hton_ptr;
@@ -709,7 +710,10 @@ int mrn_free_share_alloc(
 void mrn_free_long_term_share(MRN_LONG_TERM_SHARE *long_term_share)
 {
   MRN_DBUG_ENTER_FUNCTION();
+  {
+    mrn::Lock lock(&mrn_long_term_share_mutex);
   my_hash_delete(&mrn_long_term_share, (uchar*) long_term_share);
+  }
   pthread_mutex_destroy(&long_term_share->auto_inc_mutex);
   my_free(long_term_share, MYF(0));
   DBUG_VOID_RETURN;
@@ -723,6 +727,7 @@ MRN_LONG_TERM_SHARE *mrn_get_long_term_share(const char *table_name,
   char *tmp_name;
   MRN_DBUG_ENTER_FUNCTION();
   DBUG_PRINT("info", ("mroonga: table_name=%s", table_name));
+  mrn::Lock lock(&mrn_long_term_share_mutex);
   if (!(long_term_share = (MRN_LONG_TERM_SHARE*)
     my_hash_search(&mrn_long_term_share, (uchar*) table_name,
                    table_name_length)))
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index