Navigation Menu

Skip to content

Commit

Permalink
Ensure disposing database object
Browse files Browse the repository at this point in the history
Reported by Tomoatsu Shimada. Thanks!!!
  • Loading branch information
kou committed Jun 14, 2014
1 parent 79f8f25 commit 4c9a9c6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions groonga-gobject/ggrn-context.c
Expand Up @@ -152,11 +152,16 @@ ggrn_context_open_database(GGrnContext *context,
const gchar *path, GError **error)
{
GGrnContextPrivate *priv = GGRN_CONTEXT_GET_PRIVATE(context);
gboolean success;

dispose_database(priv);

grn_db_open(priv->ctx, path);
return _ggrn_context_check(context, error);
success = _ggrn_context_check(context, error);
if (success) {
priv->own_database = TRUE;
}
return success;
}

/**
Expand All @@ -177,11 +182,16 @@ ggrn_context_create_database(GGrnContext *context,
const gchar *path, GError **error)
{
GGrnContextPrivate *priv = GGRN_CONTEXT_GET_PRIVATE(context);
gboolean success;

dispose_database(priv);

grn_db_create(priv->ctx, path, NULL);
return _ggrn_context_check(context, error);
success = _ggrn_context_check(context, error);
if (success) {
priv->own_database = TRUE;
}
return success;
}

/**
Expand Down

2 comments on commit 4c9a9c6

@shimarin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete contextでリソースが開放されるようになりました。ありがとうございます。
リソースリークしなくなったおかげか、Groonga.fin() の呼び出しで glibcのアサートが出ていたのも出なくなりました。

@kou
Copy link
Member Author

@kou kou commented on 4c9a9c6 Jun 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確認ありがとうございます!
では、月末リリースします!

Please sign in to comment.