You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2016/04/27 12:39:30 UTC

svn commit: r1741206 - /subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c

Author: kotkov
Date: Wed Apr 27 10:39:30 2016
New Revision: 1741206

URL: http://svn.apache.org/viewvc?rev=1741206&view=rev
Log:
Explicitly close the rep-cache.db connection if we fail to run the
preparatory work, e.g., after errors when creating the schema.

An sqlite db connection is tricky enough, so don't keep it around waiting
for the cleanup of the fs->pool, if we are not going to use it at all.

* subversion/libsvn_fs_fs/rep-cache.c
  (SVN_ERR_CLOSE): New macro.
  (open_rep_cache): Wrap necessary statements with the new macro.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c?rev=1741206&r1=1741205&r2=1741206&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Wed Apr 27 10:39:30 2016
@@ -51,6 +51,13 @@ path_rep_cache_db(const char *fs_path,
   return svn_dirent_join(fs_path, REP_CACHE_DB_NAME, result_pool);
 }
 
+#define SVN_ERR_CLOSE(x, db) do                                       \
+{                                                                     \
+  svn_error_t *svn__err = (x);                                        \
+  if (svn__err)                                                       \
+    return svn_error_compose_create(svn__err, svn_sqlite__close(db)); \
+} while (0)
+
 
 /** Library-private API's. **/
 
@@ -100,12 +107,12 @@ open_rep_cache(void *baton,
                            0, NULL, 0,
                            fs->pool, pool));
 
-  SVN_ERR(svn_sqlite__read_schema_version(&version, sdb, pool));
+  SVN_ERR_CLOSE(svn_sqlite__read_schema_version(&version, sdb, pool), sdb);
   if (version < REP_CACHE_SCHEMA_FORMAT)
     {
       /* Must be 0 -- an uninitialized (no schema) database. Create
          the schema. Results in schema version of 1.  */
-      SVN_ERR(svn_sqlite__exec_statements(sdb, STMT_CREATE_SCHEMA));
+      SVN_ERR_CLOSE(svn_sqlite__exec_statements(sdb, STMT_CREATE_SCHEMA), sdb);
     }
 
   /* This is used as a flag that the database is available so don't