Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix issue with remote repo update locking.
Vsevolod Stakhov committed 11 years ago
commit 074807ed3412e08f75060ac5e38cbd9ca581cc4e
parent 9b886fd
3 files changed +15 -11
modified libpkg/pkg_repo_update.c
@@ -402,8 +402,6 @@ pkg_repo_update_incremental(const char *name, struct pkg_repo *repo, time_t *mti

cleanup:

-
	if (rc == EPKG_OK)
-
		sql_exec(sqlite, "DROP TABLE repo_update;");
	if (in_trans) {
		if (rc != EPKG_OK)
			pkgdb_transaction_rollback(sqlite, "REPO");
@@ -411,6 +409,11 @@ cleanup:
		if (pkgdb_transaction_commit(sqlite, "REPO") != EPKG_OK)
			rc = EPKG_FATAL;
	}
+

+
	pkgdb_repo_finalize_statements();
+

+
	if (rc == EPKG_OK)
+
		sql_exec(sqlite, "DROP TABLE repo_update;");
	if (pkg != NULL)
		pkg_free(pkg);
	if (it != NULL)
@@ -426,7 +429,7 @@ cleanup:
	if (linebuf != NULL)
		free(linebuf);

-
	pkgdb_repo_close(sqlite, rc == EPKG_OK);
+
	sqlite3_close(sqlite);

	return (rc);
}
modified libpkg/pkgdb_repo.c
@@ -301,8 +301,8 @@ run_prepared_statement(sql_prstmt_index s, ...)
	return (retcode);
}

-
static void
-
finalize_prepared_statements(void)
+
void
+
pkgdb_repo_finalize_statements(void)
{
	sql_prstmt_index i, last;

@@ -377,7 +377,7 @@ pkgdb_repo_init(sqlite3 *sqlite)
{
	int retcode = EPKG_OK;

-
	retcode = sql_exec(sqlite, "PRAGMA synchronous=off");
+
	retcode = sql_exec(sqlite, "PRAGMA synchronous=default");
	if (retcode != EPKG_OK)
		return (retcode);

@@ -389,10 +389,6 @@ pkgdb_repo_init(sqlite3 *sqlite)
	if (retcode != EPKG_OK)
		return (retcode);

-
	retcode = pkgdb_transaction_begin(sqlite, NULL);
-
	if (retcode != EPKG_OK)
-
		return (retcode);
-

	return (EPKG_OK);
}

@@ -412,7 +408,7 @@ pkgdb_repo_close(sqlite3 *sqlite, bool commit)
		if (pkgdb_transaction_rollback(sqlite, NULL) != SQLITE_OK)
				retcode = EPKG_FATAL;
	}
-
	finalize_prepared_statements();
+
	pkgdb_repo_finalize_statements();

	return (retcode);
}
modified libpkg/private/pkgdb.h
@@ -84,6 +84,11 @@ int pkgdb_repo_open(const char *repodb, bool force, sqlite3 **sqlite);
int pkgdb_repo_init(sqlite3 *sqlite);

/**
+
 * Finalize prepared statements for a repo
+
 */
+
void pkgdb_repo_finalize_statements(void);
+

+
/**
 * Close repodb and commit/rollback transaction started
 * @param sqlite sqlite pointer
 * @param commit commit transaction if true, rollback otherwise