lib: Define an autocleanup for RPM signal handling
Allows us to convert the metadata download func to new code style, and is generally in line with our cleanup-focused philosophy on code, life, and the meaning of the universe. Closes: #789 Approved by: jlebon
This commit is contained in:
parent
6210f34096
commit
53d259b3c3
@ -354,7 +354,7 @@ rpmostree_context_new_system (GCancellable *cancellable,
|
||||
#endif
|
||||
|
||||
self->hifctx = dnf_context_new ();
|
||||
_rpmostree_reset_rpm_sighandlers ();
|
||||
g_auto(RpmSighandlerResetCleanup) rpmsigreset = { 0, };
|
||||
dnf_context_set_http_proxy (self->hifctx, g_getenv ("http_proxy"));
|
||||
|
||||
dnf_context_set_repo_dir (self->hifctx, "/etc/yum.repos.d");
|
||||
@ -889,26 +889,21 @@ rpmostree_context_download_metadata (RpmOstreeContext *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint progress_sigid;
|
||||
glnx_unref_object DnfState *hifstate = dnf_state_new ();
|
||||
|
||||
g_assert (!self->empty);
|
||||
|
||||
progress_sigid = g_signal_connect (hifstate, "percentage-changed",
|
||||
G_CALLBACK (on_hifstate_percentage_changed),
|
||||
"Downloading metadata:");
|
||||
g_autoptr(DnfState) hifstate = dnf_state_new ();
|
||||
|
||||
guint progress_sigid = g_signal_connect (hifstate, "percentage-changed",
|
||||
G_CALLBACK (on_hifstate_percentage_changed),
|
||||
"Downloading metadata:");
|
||||
|
||||
g_auto(RpmSighandlerResetCleanup) rpmsigreset = { 0, };
|
||||
if (!dnf_context_setup_sack (self->hifctx, hifstate, error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
g_signal_handler_disconnect (hifstate, progress_sigid);
|
||||
rpmostree_output_percent_progress_end ();
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
_rpmostree_reset_rpm_sighandlers ();
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2483,8 +2478,9 @@ rpmostree_context_assemble_tmprootfs (RpmOstreeContext *self,
|
||||
}
|
||||
}
|
||||
|
||||
rpmtsOrder (ordering_ts);
|
||||
_rpmostree_reset_rpm_sighandlers ();
|
||||
{ g_auto(RpmSighandlerResetCleanup) rpmsigreset = { 0, };
|
||||
rpmtsOrder (ordering_ts);
|
||||
}
|
||||
|
||||
rpmostree_output_task_begin ("Overlaying");
|
||||
|
||||
|
@ -128,6 +128,17 @@ rpmostree_print_transaction (DnfContext *context);
|
||||
|
||||
void _rpmostree_reset_rpm_sighandlers (void);
|
||||
|
||||
/* This cleanup struct wraps _rpmostree_reset_rpm_sighandlers() */
|
||||
typedef struct {
|
||||
gpointer unused;
|
||||
} RpmSighandlerResetCleanup;
|
||||
static inline void
|
||||
cleanup_rpmsighandler_reset(RpmSighandlerResetCleanup *cleanup)
|
||||
{
|
||||
_rpmostree_reset_rpm_sighandlers ();
|
||||
}
|
||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(RpmSighandlerResetCleanup, cleanup_rpmsighandler_reset);
|
||||
|
||||
GVariant *
|
||||
rpmostree_fcap_to_xattr_variant (const char *fcap);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user