mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-31 02:35:37 +00:00
Shut down automatically when there is system memory pressure
We can just rescan hardware if required; near OOM it's just more important to free what we can and get out of the way.
This commit is contained in:
parent
d7197d5319
commit
603e4f6956
@ -7,6 +7,7 @@ RUN echo fubar > /etc/machine-id
|
|||||||
RUN dnf -y update
|
RUN dnf -y update
|
||||||
RUN echo fubar > /etc/machine-id
|
RUN echo fubar > /etc/machine-id
|
||||||
%%%INSTALL_DEPENDENCIES_COMMAND%%%
|
%%%INSTALL_DEPENDENCIES_COMMAND%%%
|
||||||
|
RUN dnf -y update glib2 glib2-devel --releasever=32
|
||||||
RUN mkdir /build
|
RUN mkdir /build
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@ -43,6 +43,9 @@ typedef struct {
|
|||||||
GDBusProxy *proxy_uid;
|
GDBusProxy *proxy_uid;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
GFileMonitor *argv0_monitor;
|
GFileMonitor *argv0_monitor;
|
||||||
|
#if GLIB_CHECK_VERSION(2,63,3)
|
||||||
|
GMemoryMonitor *memory_monitor;
|
||||||
|
#endif
|
||||||
PolkitAuthority *authority;
|
PolkitAuthority *authority;
|
||||||
guint owner_id;
|
guint owner_id;
|
||||||
FuEngine *engine;
|
FuEngine *engine;
|
||||||
@ -1464,6 +1467,23 @@ fu_main_argv_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file,
|
|||||||
g_main_loop_quit (priv->loop);
|
g_main_loop_quit (priv->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GLIB_CHECK_VERSION(2,63,3)
|
||||||
|
static void
|
||||||
|
fu_main_memory_monitor_warning_cb (GMemoryMonitor *memory_monitor,
|
||||||
|
GMemoryMonitorWarningLevel level,
|
||||||
|
FuMainPrivate *priv)
|
||||||
|
{
|
||||||
|
/* can do straight away? */
|
||||||
|
if (priv->update_in_progress) {
|
||||||
|
g_warning ("OOM during a firmware update, ignoring");
|
||||||
|
priv->pending_sigterm = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_debug ("OOM event, shutting down");
|
||||||
|
g_main_loop_quit (priv->loop);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static GDBusNodeInfo *
|
static GDBusNodeInfo *
|
||||||
fu_main_load_introspection (const gchar *filename, GError **error)
|
fu_main_load_introspection (const gchar *filename, GError **error)
|
||||||
{
|
{
|
||||||
@ -1502,6 +1522,10 @@ fu_main_private_free (FuMainPrivate *priv)
|
|||||||
g_object_unref (priv->argv0_monitor);
|
g_object_unref (priv->argv0_monitor);
|
||||||
if (priv->introspection_daemon != NULL)
|
if (priv->introspection_daemon != NULL)
|
||||||
g_dbus_node_info_unref (priv->introspection_daemon);
|
g_dbus_node_info_unref (priv->introspection_daemon);
|
||||||
|
#if GLIB_CHECK_VERSION(2,63,3)
|
||||||
|
if (priv->memory_monitor != NULL)
|
||||||
|
g_object_unref (priv->memory_monitor);
|
||||||
|
#endif
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1586,6 +1610,13 @@ main (int argc, char *argv[])
|
|||||||
g_signal_connect (priv->argv0_monitor, "changed",
|
g_signal_connect (priv->argv0_monitor, "changed",
|
||||||
G_CALLBACK (fu_main_argv_changed_cb), priv);
|
G_CALLBACK (fu_main_argv_changed_cb), priv);
|
||||||
|
|
||||||
|
#if GLIB_CHECK_VERSION(2,63,3)
|
||||||
|
/* shut down on low memory event as we can just rescan hardware */
|
||||||
|
priv->memory_monitor = g_memory_monitor_dup_default ();
|
||||||
|
g_signal_connect (G_OBJECT (priv->memory_monitor), "low-memory-warning",
|
||||||
|
G_CALLBACK (fu_main_memory_monitor_warning_cb), priv);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* load introspection from file */
|
/* load introspection from file */
|
||||||
priv->introspection_daemon = fu_main_load_introspection (FWUPD_DBUS_INTERFACE ".xml",
|
priv->introspection_daemon = fu_main_load_introspection (FWUPD_DBUS_INTERFACE ".xml",
|
||||||
&error);
|
&error);
|
||||||
|
Loading…
Reference in New Issue
Block a user