Commit 1dfcf674 authored by Martyn Russell's avatar Martyn Russell

tracker-extract: Fixed Ctrl+C not working with -d

parent f23a97d1
......@@ -153,7 +153,7 @@ tracker_dbus_shutdown (void)
}
gboolean
tracker_dbus_register_objects (void)
tracker_dbus_register_objects (gboolean disable_shutdown)
{
gpointer object;
......@@ -163,7 +163,7 @@ tracker_dbus_register_objects (void)
}
/* Add org.freedesktop.Tracker1.Extract */
object = tracker_extract_new ();
object = tracker_extract_new (disable_shutdown);
if (!object) {
g_critical ("Could not create TrackerExtract object to register");
return FALSE;
......
......@@ -30,8 +30,8 @@ G_BEGIN_DECLS
gboolean tracker_dbus_init (void);
void tracker_dbus_shutdown (void);
gboolean tracker_dbus_register_objects (void);
GObject *tracker_dbus_get_object (GType type);
gboolean tracker_dbus_register_objects (gboolean disable_shutdown);
GObject *tracker_dbus_get_object (GType type);
G_END_DECLS
......
......@@ -47,6 +47,7 @@ extern gboolean debug;
typedef struct {
GArray *specific_extractors;
GArray *generic_extractors;
gboolean disable_shutdown;
} TrackerExtractPrivate;
typedef struct {
......@@ -115,7 +116,7 @@ tracker_extract_finalize (GObject *object)
}
TrackerExtract *
tracker_extract_new (void)
tracker_extract_new (gboolean disable_shutdown)
{
TrackerExtract *object;
TrackerExtractPrivate *priv;
......@@ -202,6 +203,8 @@ tracker_extract_new (void)
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
priv->disable_shutdown = disable_shutdown;
priv->specific_extractors = specific_extractors;
priv->generic_extractors = generic_extractors;
......@@ -434,7 +437,8 @@ tracker_extract_get_metadata (TrackerExtract *object,
DBusGMethodInvocation *context,
GError **error)
{
guint request_id;
guint request_id;
TrackerExtractPrivate *priv;
TrackerSparqlBuilder *sparql = NULL;
request_id = tracker_dbus_get_next_request_id ();
......@@ -449,9 +453,11 @@ tracker_extract_get_metadata (TrackerExtract *object,
tracker_dbus_request_debug (request_id,
" Resetting shutdown timeout");
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
tracker_main_quit_timeout_reset ();
if (!debug) {
if (!priv->disable_shutdown) {
alarm (MAX_EXTRACT_TIME);
}
......@@ -477,7 +483,7 @@ tracker_extract_get_metadata (TrackerExtract *object,
g_error_free (actual_error);
}
if (!debug) {
if (!priv->disable_shutdown) {
/* Unset alarm so the extractor doesn't die when it's idle */
alarm (0);
}
......
......@@ -50,7 +50,7 @@ struct TrackerExtractClass {
};
GType tracker_extract_get_type (void);
TrackerExtract *tracker_extract_new (void);
TrackerExtract *tracker_extract_new (gboolean disable_shutdown);
void tracker_extract_get_pid (TrackerExtract *object,
DBusGMethodInvocation *context,
GError **error);
......
......@@ -70,7 +70,7 @@ static GMainLoop *main_loop;
static guint quit_timeout_id = 0;
static gboolean version;
gboolean debug = FALSE;
static gboolean disable_shutdown;
static gint verbosity = -1;
static gchar *filename;
static gchar *mime_type;
......@@ -95,9 +95,9 @@ static GOptionEntry entries[] = {
N_("MIME") },
/* Debug run is used to avoid that the mainloop exits, so that
* as a developer you can be relax when running the tool in gdb */
{ "debug", 'd', 0,
G_OPTION_ARG_NONE, &debug,
N_("Debug (default = off)"),
{ "disable-shutdown", 'd', 0,
G_OPTION_ARG_NONE, &disable_shutdown,
N_("Disable shutting down after 30 seconds of inactivity"),
NULL },
{ NULL }
......@@ -108,7 +108,7 @@ quit_timeout_cb (gpointer user_data)
{
quit_timeout_id = 0;
if (!debug) {
if (!disable_shutdown) {
g_main_loop_quit (main_loop);
} else {
g_debug ("Would have quit the mainloop");
......@@ -189,11 +189,12 @@ signal_handler (int signo)
case SIGTERM:
case SIGINT:
in_loop = TRUE;
disable_shutdown = FALSE;
quit_timeout_cb (NULL);
default:
if (g_strsignal (signo)) {
g_print ("\n");
g_print ("Received signal:%d->'%s'",
g_print ("Received signal:%d->'%s'\n",
signo,
g_strsignal (signo));
}
......@@ -310,7 +311,9 @@ main (int argc, char *argv[])
return EXIT_SUCCESS;
}
g_print ("Initializing tracker-extract...%s\n", debug ? "Running in debug mode" : "");
g_print ("Initializing tracker-extract...\n");
g_print (" Shutdown after 30 seconds of inactivitiy is %s\n",
disable_shutdown ? "disabled" : "enabled");
initialize_signal_handler ();
......@@ -339,7 +342,7 @@ main (int argc, char *argv[])
GFile *file;
gchar *uri;
extract = tracker_extract_new ();
extract = tracker_extract_new (disable_shutdown);
if (!extract) {
return EXIT_FAILURE;
}
......@@ -376,7 +379,7 @@ main (int argc, char *argv[])
g_free (log_filename);
/* Make Tracker available for introspection */
if (!tracker_dbus_register_objects ()) {
if (!tracker_dbus_register_objects (disable_shutdown)) {
g_object_unref (config);
return EXIT_FAILURE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment