Skip to content

Commit

Permalink
Fix for DecrementalRestorer fails to close sqlite file descriptor
Browse files Browse the repository at this point in the history
DecrementalRestorer does not use sqlite3_finalize() on sqlite
statements after all statements are processed using sqlite3_step().
Calling sqlite3_close() without doing a sqlite_finalize(statement)
is causing failure in closing sqlite file descriptor. This patch
adds sqlite3_finalize() statements before doing close().

Change-Id: I39c1f28b058f5078537fcb9a228b449f2af033e6
Reviewed-on: http://review.couchbase.org/12267
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information
t3rm1n4l authored and chiyoung committed Jan 11, 2012
1 parent f312aa0 commit 00223cd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions restore_impl.cc
Expand Up @@ -101,6 +101,7 @@ class DecrementalRestorer {
*/
~DecrementalRestorer() {
if (db != NULL) {
(void)sqlite3_finalize(statement);
(void)sqlite3_close(db);
}
}
Expand Down Expand Up @@ -143,6 +144,7 @@ class DecrementalRestorer {
if (sqlite3_prepare_v2(db, query,
strlen(query),
&statement, NULL) != SQLITE_OK) {
(void)sqlite3_finalize(statement);
(void)sqlite3_close(db);
db = NULL;
throw std::string("Failed to prepare statement");
Expand All @@ -161,6 +163,7 @@ class DecrementalRestorer {
}
}

(void)sqlite3_finalize(statement);
(void)sqlite3_close(db);
db = NULL;
}
Expand Down

0 comments on commit 00223cd

Please sign in to comment.