From 1e7800862e501d4310276e9d75947564d4556e2e Mon Sep 17 00:00:00 2001 From: zhengchao Date: Tue, 8 Dec 2015 13:01:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=83=85=E5=BD=A2=E4=B8=8B=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=A4=9A?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E8=AE=BF=E9=97=AEfuzzy=5Fhandle=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E5=85=B6=E6=93=8D=E4=BD=9C=E4=BD=BF=E7=94=A8mutex?= =?UTF-8?q?=E9=94=81=E4=BF=9D=E6=8A=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_api.cpp | 8 ++++++++ src/entry/Maat_rule.cpp | 2 +- src/entry/Maat_rule_internal.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index 4d8858d..3f74b14 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -1052,6 +1052,7 @@ stream_para_t Maat_stream_scan_digest_start(Maat_feather_t feather,int table_id, sp->thread_num=thread_num; sp->total_len=total_len; sp->fuzzy_hash_handle=tmp_fuzzy_handle; + pthread_mutex_init(&(sp->fuzzy_mutex),NULL); return sp; } @@ -1092,19 +1093,25 @@ int Maat_stream_scan_digest(stream_para_t * stream_para, const char * data, int { return 0; } + pthread_mutex_lock(&(sp->fuzzy_mutex)); sp->acc_scan_len+=fuzzy_feed(sp->fuzzy_hash_handle, data, (unsigned int)data_len,offset); + pthread_mutex_unlock(&(sp->fuzzy_mutex)); do_query=REACH_QUERY_THRESH(sp->total_len, sp->acc_scan_len, sp->query_point,8); if(do_query==0) { return 0; } + pthread_mutex_lock(&(sp->fuzzy_mutex)); digest_len=fuzzy_status(sp->fuzzy_hash_handle, HASH_LENGTH); + pthread_mutex_unlock(&(sp->fuzzy_mutex)); if(digest_len==0) { return 0; } digest_buff=(char*)malloc(sizeof(char)*digest_len); + pthread_mutex_lock(&(sp->fuzzy_mutex)); fuzzy_digest(sp->fuzzy_hash_handle,digest_buff, digest_len); + pthread_mutex_unlock(&(sp->fuzzy_mutex)); if(0==pthread_rwlock_tryrdlock(GIE_rwlock)) { if(GIE_handle!=NULL) @@ -1156,6 +1163,7 @@ void Maat_stream_scan_digest_end(stream_para_t* stream_para) } } fuzzy_destroy_handle(sp->fuzzy_hash_handle); + pthread_mutex_destroy(&(sp->fuzzy_mutex)); assert(sp->last_cache==NULL); assert(sp->scan_buff==NULL); free(sp); diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index bfe5ee9..0f5ff57 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -24,7 +24,7 @@ #include "mesa_fuzzy.h" #include "great_index_engine.h" -int MAAT_FRAME_VERSION_1_3_20151119=0; +int MAAT_FRAME_VERSION_1_3_20151208=0; const char *maat_module="MAAT Frame"; const char* CHARSET_STRING[]={"CHARSET_NONE","GBK","BIG5","UNICODE","UTF-8"}; diff --git a/src/entry/Maat_rule_internal.h b/src/entry/Maat_rule_internal.h index 37008a3..8fb0931 100644 --- a/src/entry/Maat_rule_internal.h +++ b/src/entry/Maat_rule_internal.h @@ -263,6 +263,7 @@ struct _stream_para_t long acc_scan_len; unsigned long long total_len; fuzzy_handle_t *fuzzy_hash_handle; + pthread_mutex_t fuzzy_mutex; unsigned char query_point[8]; }; struct _Maat_scanner_t