[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] added global mutex object added mutex-lock on mrn_flush_logs modified: src/ha_groonga.cc

Back to archive index

Tetsuro IKEDA null+****@clear*****
Thu Oct 4 10:18:10 JST 2012


Tetsuro IKEDA	2009-02-06 18:08:00 +0900 (Fri, 06 Feb 2009)

  New Revision: d3b750992aa7dc741d63b10ec94fd487d83e39c9
  https://github.com/mroonga/mroonga/commit/d3b750992aa7dc741d63b10ec94fd487d83e39c9

  Log:
    added global mutex object added mutex-lock on mrn_flush_logs 	modified:   src/ha_groonga.cc

  Modified files:
    src/ha_groonga.cc

  Modified: src/ha_groonga.cc (+9 -0)
===================================================================
--- src/ha_groonga.cc    2009-02-06 15:15:21 +0900 (d1a36c0)
+++ src/ha_groonga.cc    2009-02-06 18:08:00 +0900 (36c9df4)
@@ -2,7 +2,9 @@
 #include <mysql/plugin.h>
 #include <groonga.h>
 #include "ha_groonga.h"
+#include <pthread.h>
 
+pthread_mutex_t mrn_mutex_sys;
 grn_ctx *mrn_ctx_sys;
 const char *mrn_log_name="groonga.log";
 static FILE *mrn_log_file = NULL;
@@ -155,11 +157,13 @@ void ha_groonga::position(const uchar *record)
 bool mrn_flush_logs(handlerton *hton)
 {
   MRN_ENTER;
+  pthread_mutex_lock(&mrn_mutex_sys);
   MRN_LOG(GRN_LOG_NOTICE, "logfile closed by FLUSH LOGS");
   fflush(mrn_log_file);
   fclose(mrn_log_file);
   mrn_log_file = fopen(mrn_log_name, "a");
   MRN_LOG(GRN_LOG_NOTICE, "logfile re-opened by FLUSH LOGS");
+  pthread_mutex_unlock(&mrn_mutex_sys);
   MRN_RETURN(true);
 }
 
@@ -172,13 +176,18 @@ static int mrn_init(void *p)
   hton->create = mrn_handler_create;
   hton->flush_logs = mrn_flush_logs;
   hton->flags = 0;
+
+  pthread_mutex_init(&mrn_mutex_sys, MY_MUTEX_INIT_FAST);
+
   grn_init();
   mrn_ctx_sys = (grn_ctx *) malloc(sizeof (grn_ctx));
   grn_ctx_init(mrn_ctx_sys, GRN_CTX_USE_DB, GRN_ENC_UTF8);
+
   if (!(mrn_log_file = fopen(mrn_log_name, "a"))) {
     MRN_RETURN(-1);
   }
   grn_logger_info_set(mrn_ctx_sys, &mrn_logger_info);
+
   MRN_LOG(GRN_LOG_NOTICE, "gronnga engine started");
   MRN_RETURN(0);
 }
-------------- next part --------------
HTML����������������������������...
다운로드 



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