Kouhei Sutou
null+****@clear*****
Fri Sep 25 17:26:37 JST 2015
Kouhei Sutou 2015-09-25 17:26:37 +0900 (Fri, 25 Sep 2015) New Revision: d18095c4f51bffdf7361e0318ce4c4eb34b3c0d3 https://github.com/groonga/groonga/commit/d18095c4f51bffdf7361e0318ce4c4eb34b3c0d3 Message: groonga: mutex and cond are always initialized Even when stand alone mode. Because thread_limit command use them. Modified files: lib/grn.h src/groonga.c Modified: lib/grn.h (+9 -1) =================================================================== --- lib/grn.h 2015-09-25 16:44:41 +0900 (c5151db) +++ lib/grn.h 2015-09-25 17:26:37 +0900 (e999831) @@ -226,7 +226,7 @@ typedef pthread_mutex_t grn_mutex; # define MUTEX_LOCK(m) pthread_mutex_lock(&m) # define MUTEX_LOCK_CHECK(m) (MUTEX_LOCK(m) == 0) # define MUTEX_UNLOCK(m) pthread_mutex_unlock(&m) -# define MUTEX_FIN(m) +# define MUTEX_FIN(m) pthread_mutex_destroy(&m) # ifdef HAVE_PTHREAD_MUTEXATTR_SETPSHARED # define MUTEX_INIT_SHARED(m) do {\ pthread_mutexattr_t mutexattr;\ @@ -259,6 +259,7 @@ typedef pthread_cond_t grn_cond; # else # define COND_INIT_SHARED COND_INIT # endif /* HAVE_PTHREAD_CONDATTR_SETPSHARE */ +# define COND_FIN(c) pthread_cond_destroy(&c) typedef pthread_key_t grn_thread_key; # define THREAD_KEY_CREATE(key, destr) pthread_key_create(key, destr) @@ -393,6 +394,12 @@ typedef struct } \ } while (0) +# define COND_FIN(c) do { \ + CloseHandle((c).waiters_done_); \ + MUTEX_FIN((c).waiters_count_lock_); \ + CloseHandle((c).sema_); \ +} while (0) + # else /* WIN32 */ /* todo */ typedef int grn_cond; @@ -403,6 +410,7 @@ typedef int grn_cond; grn_nanosleep(1000000); \ MUTEX_LOCK(m); \ } while (0) +# define COND_FIN(c) /* todo : must be enhanced! */ # endif /* WIN32 */ Modified: src/groonga.c (+8 -6) =================================================================== --- src/groonga.c 2015-09-25 16:44:41 +0900 (6b27d21) +++ src/groonga.c 2015-09-25 17:26:37 +0900 (d089d7f) @@ -2007,9 +2007,6 @@ h_server(char *path) int exit_code = EXIT_FAILURE; grn_ctx ctx_, *ctx = &ctx_; grn_ctx_init(ctx, 0); - MUTEX_INIT(q_mutex); - COND_INIT(q_cond); - CRITICAL_SECTION_INIT(cache_lock); GRN_COM_QUEUE_INIT(&ctx_new); GRN_COM_QUEUE_INIT(&ctx_old); check_rlimit_nofile(ctx); @@ -2172,9 +2169,6 @@ g_server(char *path) int exit_code = EXIT_FAILURE; grn_ctx ctx_, *ctx = &ctx_; grn_ctx_init(ctx, 0); - MUTEX_INIT(q_mutex); - COND_INIT(q_cond); - CRITICAL_SECTION_INIT(cache_lock); GRN_COM_QUEUE_INIT(&ctx_new); GRN_COM_QUEUE_INIT(&ctx_old); check_rlimit_nofile(ctx); @@ -3193,6 +3187,10 @@ main(int argc, char **argv) grn_cache_set_max_n_entries(&grn_gctx, cache, cache_limit); } + MUTEX_INIT(q_mutex); + COND_INIT(q_cond); + CRITICAL_SECTION_INIT(cache_lock); + newdb = (flags & FLAG_NEW_DB); is_daemon_mode = (flags & FLAG_MODE_DAEMON); if (flags & FLAG_MODE_CLIENT) { @@ -3203,6 +3201,10 @@ main(int argc, char **argv) exit_code = do_alone(argc - i, argv + i); } + CRITICAL_SECTION_FIN(cache_lock); + COND_FIN(q_cond); + MUTEX_FIN(q_mutex); + #ifdef GRN_WITH_LIBEDIT if (need_line_editor) { line_editor_fin(); -------------- next part -------------- HTML����������������������������... 下載