Use ShutdownTimeout from the config file
This commit is contained in:
parent
9c25389eb6
commit
8accd01eb4
@ -44,6 +44,8 @@ packagekitd_SOURCES = \
|
|||||||
pk-backend-internal.h \
|
pk-backend-internal.h \
|
||||||
pk-backend.c \
|
pk-backend.c \
|
||||||
pk-backend.h \
|
pk-backend.h \
|
||||||
|
pk-conf.c \
|
||||||
|
pk-conf.h \
|
||||||
pk-spawn.c \
|
pk-spawn.c \
|
||||||
pk-spawn.h \
|
pk-spawn.h \
|
||||||
pk-engine.h \
|
pk-engine.h \
|
||||||
|
@ -31,10 +31,11 @@
|
|||||||
#include <dbus/dbus-glib-lowlevel.h>
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
|
||||||
#include <pk-debug.h>
|
#include <pk-debug.h>
|
||||||
|
#include "pk-conf.h"
|
||||||
#include "pk-engine.h"
|
#include "pk-engine.h"
|
||||||
#include "pk-interface.h"
|
#include "pk-interface.h"
|
||||||
|
|
||||||
#define PK_MAIN_EXIT_IDLE_TIME 60 /* seconds */
|
static guint exit_idle_time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pk_object_register:
|
* pk_object_register:
|
||||||
@ -115,7 +116,7 @@ pk_main_timeout_check_cb (PkEngine *engine)
|
|||||||
guint idle;
|
guint idle;
|
||||||
idle = pk_engine_get_seconds_idle (engine);
|
idle = pk_engine_get_seconds_idle (engine);
|
||||||
pk_debug ("idle is %i", idle);
|
pk_debug ("idle is %i", idle);
|
||||||
if (idle > PK_MAIN_EXIT_IDLE_TIME) {
|
if (idle > exit_idle_time) {
|
||||||
pk_warning ("exit!!");
|
pk_warning ("exit!!");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
@ -137,6 +138,7 @@ main (int argc, char *argv[])
|
|||||||
gboolean timed_exit = FALSE;
|
gboolean timed_exit = FALSE;
|
||||||
gboolean immediate_exit = FALSE;
|
gboolean immediate_exit = FALSE;
|
||||||
gchar *backend = NULL;
|
gchar *backend = NULL;
|
||||||
|
PkConf *conf = NULL;
|
||||||
PkEngine *engine = NULL;
|
PkEngine *engine = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
@ -207,6 +209,11 @@ main (int argc, char *argv[])
|
|||||||
* 'it works from the command line but not service activation' bugs */
|
* 'it works from the command line but not service activation' bugs */
|
||||||
clearenv ();
|
clearenv ();
|
||||||
|
|
||||||
|
/* use the config file */
|
||||||
|
conf = pk_conf_new ();
|
||||||
|
exit_idle_time = pk_conf_get_int (conf, "ShutdownTimeout");
|
||||||
|
pk_debug ("daemon shutdown set to %i seconds", exit_idle_time);
|
||||||
|
|
||||||
/* create a new engine object */
|
/* create a new engine object */
|
||||||
engine = pk_engine_new ();
|
engine = pk_engine_new ();
|
||||||
pk_engine_use_backend (engine, backend);
|
pk_engine_use_backend (engine, backend);
|
||||||
@ -225,7 +232,7 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* only poll every 10 seconds when we are alive */
|
/* only poll every 10 seconds when we are alive */
|
||||||
if (disable_timer == FALSE) {
|
if (exit_idle_time != 0 && disable_timer == FALSE) {
|
||||||
g_timeout_add_seconds (5, (GSourceFunc) pk_main_timeout_check_cb, engine);
|
g_timeout_add_seconds (5, (GSourceFunc) pk_main_timeout_check_cb, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +241,7 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
g_object_unref (conf);
|
||||||
g_object_unref (engine);
|
g_object_unref (engine);
|
||||||
|
|
||||||
unref_program:
|
unref_program:
|
||||||
|
Loading…
Reference in New Issue
Block a user