To avoid that we mount and umount the entire environment over and over
again we mount it once for the transaction and keep a reference counter
to remember when to umount again.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
pakfire_log_function_t log_function;
int log_priority;
+ int activated;
int nrefs;
};
if (strcmp(pakfire->path, "/") == 0)
return 0;
+ // Do nothing if this already activated
+ if (pakfire->activated++)
+ return 0;
+
// Mount filesystems
int r = pakfire_mount(pakfire);
if (r) {
}
PAKFIRE_EXPORT int pakfire_deactivate(Pakfire pakfire) {
+ // Do nothing if there are some activations left
+ if (--pakfire->activated > 0)
+ return 0;
+
return pakfire_umount(pakfire);
}
DEBUG(transaction->pakfire, "Running Transaction %p\n", transaction);
+ // Activate Pakfire
+ r = pakfire_activate(transaction->pakfire);
+ if (r)
+ return r;
+
// Open the database
r = pakfire_db_open(&db, transaction->pakfire, PAKFIRE_DB_READWRITE);
if (r) {
// Free the database
pakfire_db_unref(db);
+ // Deactivate Pakfire
+ pakfire_deactivate(transaction->pakfire);
+
return r;
}