null+****@clear*****
null+****@clear*****
2012年 7月 18日 (水) 18:49:11 JST
Kouhei Sutou 2012-07-18 18:49:11 +0900 (Wed, 18 Jul 2012) New Revision: 7a662965668980ec52cc136cd6f56c8b3f9b1043 https://github.com/groonga/groonga/commit/7a662965668980ec52cc136cd6f56c8b3f9b1043 Merged da0811d: Merge pull request #21 from groonga/support-locked-database-open Log: Support locked database open Modified files: lib/db.c test/unit/core/test-database.c Modified: lib/db.c (+2 -0) =================================================================== --- lib/db.c 2012-07-18 18:15:24 +0900 (84384cd) +++ lib/db.c 2012-07-18 18:49:11 +0900 (ce8647f) @@ -517,6 +517,7 @@ grn_proc_create(grn_ctx *ctx, const char *name, unsigned int name_size, grn_proc } if (name && name_size) { grn_db *s = (grn_db *)db; + if (!(id = grn_table_get(ctx, s->keys, name, name_size))) { if (!(id = grn_table_add(ctx, s->keys, name, name_size, &added))) { ERR(GRN_NO_MEMORY_AVAILABLE, "grn_table_add failed"); GRN_API_RETURN(NULL); @@ -532,6 +533,7 @@ grn_proc_create(grn_ctx *ctx, const char *name, unsigned int name_size, grn_proc added = 1; } } + } } else if (ctx->impl && ctx->impl->values) { id = grn_array_add(ctx, ctx->impl->values, NULL) | GRN_OBJ_TMP_OBJECT; added = 1; Modified: test/unit/core/test-database.c (+16 -0) =================================================================== --- test/unit/core/test-database.c 2012-07-18 18:15:24 +0900 (b792615) +++ test/unit/core/test-database.c 2012-07-18 18:49:11 +0900 (3d3afcc) @@ -33,6 +33,7 @@ void test_expire_cache_on_recreate(void); void test_expression_lifetime_over_database(void); void test_get(void); void test_at(void); +void test_lock(void); static gchar *tmp_directory; @@ -305,3 +306,18 @@ test_at(void) GRN_DB_SHORT_TEXT, grn_table_at(context, database, GRN_DB_SHORT_TEXT)); } + +void +test_lock(void) +{ + const gchar *path; + + path = cut_build_path(tmp_directory, "database.groonga", NULL); + database = grn_db_create(context, path, NULL); + grn_obj_lock(context, database, GRN_ID_NIL, 0); + cut_assert_true(grn_obj_is_locked(context, database)); + + database2 = grn_db_open(context2, path); + grn_obj_unlock(context2, database2, GRN_ID_NIL); + cut_assert_false(grn_obj_is_locked(context, database)); +} -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Download