Navigation Menu

Skip to content

Commit

Permalink
Add missing lock for table creation
Browse files Browse the repository at this point in the history
It may fix a crash bug of mroonga:
https://gist.github.com/y-ken/9a5d564d37a58e810abe

Reported by Y.Kentaro. Thanks!!!
  • Loading branch information
kou committed Jun 5, 2013
1 parent 27f5e4b commit 1f1a774
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/db.c
Expand Up @@ -870,6 +870,10 @@ grn_table_create(grn_ctx *ctx, const char *name, unsigned int name_size,
}
calc_rec_size(flags, &max_n_subrecs, &subrec_size,
&subrec_offset, &key_size, &value_size);
{
grn_io *db_io;
db_io = grn_obj_io(db);
if (!grn_io_lock(ctx, db_io, 10000000)) {
switch (flags & GRN_OBJ_TABLE_TYPE_MASK) {
case GRN_OBJ_TABLE_HASH_KEY :
res = (grn_obj *)grn_hash_create(ctx, path, key_size, value_size, flags);
Expand All @@ -884,6 +888,9 @@ grn_table_create(grn_ctx *ctx, const char *name, unsigned int name_size,
domain = range;
res = (grn_obj *)grn_array_create(ctx, path, value_size, flags);
break;
}
grn_io_unlock(db_io);
}
}
if (res) {
DB_OBJ(res)->header.impl_flags = 0;
Expand Down

0 comments on commit 1f1a774

Please sign in to comment.