[darwinbuild-changes] [784] branches/PR-7748469/darwinup
source_changes at macosforge.org
source_changes at macosforge.org
Sun Mar 14 23:46:25 PDT 2010
Revision: 784
http://trac.macosforge.org/projects/darwinbuild/changeset/784
Author: wsiegrist at apple.com
Date: 2010-03-14 23:46:24 -0700 (Sun, 14 Mar 2010)
Log Message:
-----------
Use a global exclusive lock on the depot
Modified Paths:
--------------
branches/PR-7748469/darwinup/Database.cpp
branches/PR-7748469/darwinup/Depot.cpp
Modified: branches/PR-7748469/darwinup/Database.cpp
===================================================================
--- branches/PR-7748469/darwinup/Database.cpp 2010-03-15 05:47:50 UTC (rev 783)
+++ branches/PR-7748469/darwinup/Database.cpp 2010-03-15 06:46:24 UTC (rev 784)
@@ -123,7 +123,7 @@
}
int exists = is_regular_file(m_path);
- __retry_if_locked(sqlite3_open(m_path, &m_db));
+ res = sqlite3_open(m_path, &m_db);
if (res) {
sqlite3_close(m_db);
m_db = NULL;
@@ -452,7 +452,7 @@
return res;
}
this->bind_columns(stmt, count, param, args);
- __retry_if_locked(sqlite3_step(stmt));
+ res = sqlite3_step(stmt);
sqlite3_reset(stmt);
cache_release_value(m_statement_cache, pps);
va_end(args);
@@ -553,7 +553,7 @@
char* error;
if (this->m_db) {
char *query = sqlite3_vmprintf(fmt, args);
- __retry_if_locked(sqlite3_exec(this->m_db, query, NULL, NULL, &error));
+ res = sqlite3_exec(this->m_db, query, NULL, NULL, &error);
sqlite3_free(query);
} else {
fprintf(stderr, "Error: database not open.\n");
@@ -594,7 +594,7 @@
int Database::execute(sqlite3_stmt* stmt) {
int res = SQLITE_OK;
- __retry_if_locked(sqlite3_step(stmt));
+ res = sqlite3_step(stmt);
if (res == SQLITE_DONE) {
res = SQLITE_OK;
} else {
@@ -634,7 +634,7 @@
int res = SQLITE_OK;
char* query;
asprintf(&query, "SELECT count(*) FROM %s;", m_tables[0]->name());
- __retry_if_locked(sqlite3_exec(this->m_db, query, NULL, NULL, NULL));
+ res = sqlite3_exec(this->m_db, query, NULL, NULL, NULL);
free(query);
return res != SQLITE_OK;
}
@@ -772,9 +772,9 @@
bool Database::has_information_table() {
int res = SQLITE_OK;
- __retry_if_locked(sqlite3_exec(this->m_db,
- "SELECT count(*) FROM database_information;",
- NULL, NULL, NULL));
+ res = sqlite3_exec(this->m_db,
+ "SELECT count(*) FROM database_information;",
+ NULL, NULL, NULL);
return res == SQLITE_OK;
}
@@ -852,7 +852,7 @@
*/
int Database::step_once(sqlite3_stmt* stmt, uint8_t* output, uint32_t* used) {
int res = SQLITE_OK;
- __retry_if_locked(sqlite3_step(stmt));
+ res = sqlite3_step(stmt);
uint8_t* current = output;
if (used) *used = 0;
if (res == SQLITE_ROW) {
Modified: branches/PR-7748469/darwinup/Depot.cpp
===================================================================
--- branches/PR-7748469/darwinup/Depot.cpp 2010-03-15 05:47:50 UTC (rev 783)
+++ branches/PR-7748469/darwinup/Depot.cpp 2010-03-15 06:46:24 UTC (rev 784)
@@ -148,14 +148,18 @@
fprintf(stdout, "You must be root to perform that operation.\n");
exit(3);
}
+
res = this->create_storage();
if (res) return res;
- res = this->lock(LOCK_SH);
- if (res) return res;
- m_is_locked = 1;
- res = build_number_for_path(&m_build, m_prefix);
+
+ build_number_for_path(&m_build, m_prefix);
}
+ // take an exclusive lock
+ res = this->lock(LOCK_EX);
+ if (res) return res;
+ m_is_locked = 1;
+
struct stat sb;
res = stat(m_database_path, &sb);
if (!writable && res == -1 && (errno == ENOENT || errno == ENOTDIR)) {
@@ -679,7 +683,6 @@
assert(rollback != NULL);
assert(archive != NULL);
- res = this->lock(LOCK_EX);
if (res != 0) return res;
//
@@ -718,7 +721,6 @@
remove_directory(rollback_path);
free(rollback_path);
free(archive_path);
- (void)this->lock(LOCK_SH);
return res;
}
@@ -771,8 +773,6 @@
remove_directory(rollback_path);
free(rollback_path);
free(archive_path);
-
- (void)this->lock(LOCK_SH);
return res;
}
@@ -941,8 +941,7 @@
archive->name(), archive->build(), m_build);
return 9999;
}
-
- res = this->lock(LOCK_EX);
+
if (res != 0) return res;
if (!dryrun) {
@@ -981,8 +980,6 @@
if (res == 0) fprintf(stdout, "Uninstalled archive: %llu %s \n",
archive->serial(), archive->name());
-
- (void)this->lock(LOCK_SH);
return res;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100314/cbfd6b9d/attachment-0001.html>
More information about the darwinbuild-changes
mailing list