Skip to content

Commit

Permalink
fixup! daemon: Make "diff" methods safer
Browse files Browse the repository at this point in the history
Also hold the writer lock when pulling remote "/usr/share/rpm" for
package diffs.
  • Loading branch information
mbarnes committed Sep 9, 2015
1 parent 8f597ac commit 5d01190
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/daemon/rpmostreed-sysroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ struct _RpmostreedSysroot {

/* The OS interface's various diff methods can run concurrently with
* transactions, which is safe except when the transaction is writing
* new deployments to disk. Protect these critical sections with the
* writer lock, and have the diff methods hold reader locks. */
* new deployments to disk or downloading RPM package details. The
* writer lock protects these critical sections so the diff methods
* (holding reader locks) can run safely. */
GRWLock method_rw_lock;

GFileMonitor *monitor;
Expand Down
31 changes: 28 additions & 3 deletions src/daemon/rpmostreed-transaction-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@ safe_sysroot_upgrader_deploy (OstreeSysrootUpgrader *upgrader,
return success;
}

static gboolean
safe_sysroot_upgrader_pull_package_diff (OstreeSysrootUpgrader *upgrader,
OstreeAsyncProgress *progress,
gboolean *out_changed,
GCancellable *cancellable,
GError **error)
{
RpmostreedSysroot *global_sysroot = rpmostreed_sysroot_get ();
gboolean success;

rpmostreed_sysroot_writer_lock (global_sysroot);

success = ostree_sysroot_upgrader_pull_one_dir (upgrader,
"/usr/share/rpm",
0, 0,
progress,
out_changed,
cancellable,
error);

rpmostreed_sysroot_writer_unlock (global_sysroot);

return success;
}

static gboolean
safe_sysroot_write_deployments (OstreeSysroot *sysroot,
GPtrArray *deployments,
Expand Down Expand Up @@ -192,9 +217,9 @@ package_diff_transaction_execute (RpmostreedTransaction *transaction,
progress = ostree_async_progress_new ();
rpmostreed_transaction_connect_download_progress (transaction, progress);
rpmostreed_transaction_connect_signature_progress (transaction, repo);
if (!ostree_sysroot_upgrader_pull_one_dir (upgrader, "/usr/share/rpm",
0, 0, progress, &changed,
cancellable, error))

if (!safe_sysroot_upgrader_pull_package_diff (upgrader, progress, &changed,
cancellable, error))
goto out;

rpmostree_transaction_emit_progress_end (RPMOSTREE_TRANSACTION (transaction));
Expand Down

0 comments on commit 5d01190

Please sign in to comment.