summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/apk.c6
-rw-r--r--src/apk_database.h3
-rw-r--r--src/database.c7
3 files changed, 8 insertions, 8 deletions
diff --git a/src/apk.c b/src/apk.c
index 8575f66..315fa8a 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -235,7 +235,7 @@ int main(int argc, char **argv)
struct apk_applet *applet;
char short_options[256], *sopt;
struct option *opt, *all_options;
- int r, optindex, num_options, apk_wait = 0;
+ int r, optindex, num_options;
void *ctx = NULL;
struct apk_repository_list *repo = NULL;
struct apk_database db;
@@ -328,7 +328,7 @@ int main(int argc, char **argv)
apk_flags |= APK_PURGE;
break;
case 0x105:
- apk_wait = atoi(optarg);
+ dbopts.lock_wait = atoi(optarg);
break;
case 0x109:
apk_flags |= APK_NO_NETWORK;
@@ -356,7 +356,7 @@ int main(int argc, char **argv)
argv++;
}
- r = apk_db_open(&db, &dbopts, apk_wait);
+ r = apk_db_open(&db, &dbopts);
if (r != 0) {
apk_error("Failed to open apk database: %s",
apk_error_str(r));
diff --git a/src/apk_database.h b/src/apk_database.h
index ffb1bce..da33289 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -90,6 +90,7 @@ struct apk_repository_list {
};
struct apk_db_options {
+ int lock_wait;
unsigned long open_flags;
char *root;
char *keys_dir;
@@ -155,7 +156,7 @@ struct apk_db_file *apk_db_file_query(struct apk_database *db,
APK_OPENF_NO_SCRIPTS | \
APK_OPENF_NO_WORLD)
-int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts, int apk_wait);
+int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts);
void apk_db_close(struct apk_database *db);
int apk_db_write_config(struct apk_database *db);
int apk_db_run_triggers(struct apk_database *db);
diff --git a/src/database.c b/src/database.c
index 3d49c9e..e7d6b4e 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1025,8 +1025,7 @@ static void handle_alarm(int sig)
{
}
-int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts,
- int apk_wait)
+int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
{
const char *msg = NULL;
struct apk_repository_list *repo = NULL;
@@ -1086,7 +1085,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts,
if (db->lock_fd < 0 ||
flock(db->lock_fd, LOCK_EX | LOCK_NB) < 0) {
msg = "Unable to lock database";
- if (apk_wait) {
+ if (dbopts->lock_wait) {
struct sigaction sa, old_sa;
apk_message("Waiting for repository lock");
@@ -1095,7 +1094,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts,
sa.sa_flags = SA_ONESHOT;
sigaction(SIGALRM, &sa, &old_sa);
- alarm(apk_wait);
+ alarm(dbopts->lock_wait);
if (flock(db->lock_fd, LOCK_EX) < 0)
goto ret_errno;