lib/repo: Make locking timeout configurable
authorColin Walters <walters@verbum.org>
Wed, 13 Dec 2017 19:20:30 +0000 (14:20 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 14 Dec 2017 15:48:38 +0000 (15:48 +0000)
I want to make locking fully configurable (and probably off by default for now).
This is a prep commit for that.

Closes: #1375
Approved by: jlebon

src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c

index 764540a2239262125265233ce320707ca522eff6..4bbf6a06ddfdb529a9f48b0691be98797e196865 100644 (file)
@@ -37,8 +37,6 @@ G_BEGIN_DECLS
 #define _OSTREE_MAX_OUTSTANDING_FETCHER_REQUESTS 8
 #define _OSTREE_MAX_OUTSTANDING_DELTAPART_REQUESTS 2
 
-#define _OSTREE_DEFAULT_LOCK_TIMEOUT_SECONDS 30
-
 /* In most cases, writing to disk should be much faster than
  * fetching from the network, so we shouldn't actually hit
  * this. But if using pipelining and e.g. pulling over LAN
index 08a6276b0e5e54793053f299b5ffb9feb4a50c4f..e5ffba915bab2a0d47fc8c4b0a8b6289a1640864 100644 (file)
@@ -1209,7 +1209,6 @@ ostree_repo_init (OstreeRepo *self)
   self->objects_dir_fd = -1;
   self->uncompressed_objects_dir_fd = -1;
   self->sysroot_kind = OSTREE_REPO_SYSROOT_KIND_UNKNOWN;
-  self->lock_timeout_seconds = _OSTREE_DEFAULT_LOCK_TIMEOUT_SECONDS;
 }
 
 /**
@@ -2734,6 +2733,15 @@ reload_core_config (OstreeRepo          *self,
     self->tmp_expiry_seconds = g_ascii_strtoull (tmp_expiry_seconds, NULL, 10);
   }
 
+  { g_autofree char *lock_timeout_seconds = NULL;
+
+    if (!ot_keyfile_get_value_with_default (self->config, "core", "lock-timeout-secs", "30",
+                                            &lock_timeout_seconds, error))
+      return FALSE;
+
+    self->lock_timeout_seconds = g_ascii_strtoull (lock_timeout_seconds, NULL, 10);
+  }
+
   { g_autofree char *compression_level_str = NULL;
 
     /* gzip defaults to 6 */