[tracker/libtracker-common-cleanup] libtracker-common: There is no longer an os-depedent module/API
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-common-cleanup] libtracker-common: There is no longer an os-depedent module/API
- Date: Mon, 13 Oct 2014 10:44:36 +0000 (UTC)
commit 0c747da27ea4257ee91cc27995caf1782b2110bf
Author: Martyn Russell <martyn lanedo com>
Date: Mon Oct 13 11:38:14 2014 +0100
libtracker-common: There is no longer an os-depedent module/API
This means:
- all tracker_spawn*() API is removed, now using g_spawn*()
- the mplayer extractor has been removed (no one uses it anyway)
- the setrlimits() API has also been removed (only tracker-extract uses it)
- many includes have been cleaned up (this is a really old header)
- strnlen() definitions (for OS' without this API) are defined locally (only 2
cases).
configure.ac | 9 +-
src/libtracker-common/Makefile.am | 8 -
src/libtracker-common/tracker-common.h | 1 -
src/libtracker-common/tracker-file-utils.c | 2 +-
src/libtracker-common/tracker-os-dependant-unix.c | 360 --------------------
src/libtracker-common/tracker-os-dependant-win.c | 182 ----------
src/libtracker-common/tracker-os-dependant.h | 59 ----
src/libtracker-data/tracker-data-backup.c | 110 ++++---
src/libtracker-data/tracker-db-journal.c | 11 +
src/tracker-control/tracker-control-general.c | 2 +-
src/tracker-extract/93-mplayer-generic.rule | 4 -
src/tracker-extract/Makefile.am | 18 +-
src/tracker-extract/tracker-extract-mp3.c | 11 +
src/tracker-extract/tracker-extract-mplayer.c | 302 ----------------
src/tracker-extract/tracker-extract-msoffice-xml.c | 3 -
src/tracker-extract/tracker-extract-msoffice.c | 6 +-
src/tracker-extract/tracker-extract-oasis.c | 4 +-
src/tracker-extract/tracker-extract-ps.c | 45 +++-
tests/libtracker-data/tracker-backup-test.c | 2 +-
tests/libtracker-data/tracker-sparql-test.c | 2 +-
20 files changed, 144 insertions(+), 997 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c80454e..61fa1c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1798,7 +1798,7 @@ fi
AM_CONDITIONAL(HAVE_XSLTPROC, test -n "$XSLTPROC")
####################################################################
-# Check for tracker-extract: gstreamer/mplayer/etc
+# Check for tracker-extract: gstreamer/etc
####################################################################
AC_ARG_ENABLE(generic-media-extractor,
@@ -1874,17 +1874,10 @@ if test "$have_generic_media_handler_app" = "GStreamer"; then
AC_DEFINE(HAVE_GSTREAMER, [], [Define if we have GStreamer])
AM_CONDITIONAL(HAVE_GSTREAMER, true)
AM_CONDITIONAL(HAVE_LIBAV, false)
- AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, false)
elif test "$have_generic_media_handler_app" = "libav"; then
AC_DEFINE(HAVE_GSTREAMER, [], [Define if we have libav])
AM_CONDITIONAL(HAVE_LIBAV, true)
AM_CONDITIONAL(HAVE_GSTREAMER, false)
- AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, false)
-else
- AC_DEFINE(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, [], [Define that Tracker will try to use external generic
media players])
- AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, true)
- AM_CONDITIONAL(HAVE_GSTREAMER, false)
- AM_CONDITIONAL(HAVE_LIBAV, false)
fi
###########################################################################
diff --git a/src/libtracker-common/Makefile.am b/src/libtracker-common/Makefile.am
index a7a4c0c..88513be 100644
--- a/src/libtracker-common/Makefile.am
+++ b/src/libtracker-common/Makefile.am
@@ -9,15 +9,8 @@ AM_CPPFLAGS = \
libtracker_commondir = $(libdir)/tracker-$(TRACKER_API_VERSION)
libtracker_common_LTLIBRARIES = libtracker-common.la
-if OS_WIN32
-os_sources = tracker-os-dependant-win.c
-else
-os_sources = tracker-os-dependant-unix.c
-endif
-
libtracker_common_la_SOURCES = \
$(BUILT_SOURCES) \
- $(os_sources) \
tracker-date-time.c \
tracker-dbus.c \
tracker-file-utils.c \
@@ -34,7 +27,6 @@ noinst_HEADERS = \
tracker-enums.h \
tracker-ioprio.h \
tracker-log.h \
- tracker-os-dependant.h \
tracker-common.h \
tracker-date-time.h \
tracker-file-utils.h \
diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h
index a376d41..ebceba4 100644
--- a/src/libtracker-common/tracker-common.h
+++ b/src/libtracker-common/tracker-common.h
@@ -34,7 +34,6 @@
#include "tracker-ioprio.h"
#include "tracker-language.h"
#include "tracker-log.h"
-#include "tracker-os-dependant.h"
#include "tracker-sched.h"
#include "tracker-storage.h"
#include "tracker-type-utils.h"
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index c4ad77e..22322d9 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -35,10 +35,10 @@
#endif
#include <glib.h>
+#include <glib/gstdio.h>
#include <gio/gio.h>
#include "tracker-log.h"
-#include "tracker-os-dependant.h"
#include "tracker-file-utils.h"
#include "tracker-type-utils.h"
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 91e240e..1d6d4b9 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -24,8 +24,7 @@
#include <glib.h>
#include <glib/gstdio.h>
-
-#include <libtracker-common/tracker-os-dependant.h>
+#include <glib/gi18n.h>
#include "tracker-data-backup.h"
#include "tracker-data-manager.h"
@@ -413,22 +412,24 @@ restore_from_temp (void)
}
void
-tracker_data_backup_save (GFile *destination,
- TrackerDataBackupFinished callback,
- gpointer user_data,
- GDestroyNotify destroy)
+tracker_data_backup_save (GFile *destination,
+ TrackerDataBackupFinished callback,
+ gpointer user_data,
+ GDestroyNotify destroy)
{
#ifndef DISABLE_JOURNAL
BackupSaveInfo *info;
ProcessContext *context;
gchar **argv;
gchar *path, *directory;
+ GError *local_error = NULL;
GDir *journal_dir;
GFile *parent;
- GIOChannel *stdin_channel, *stdout_channel, *stderr_channel;
GPid pid;
GPtrArray *files;
const gchar *f_name;
+ gboolean result;
+ gint stdin_fd, stdout_fd, stderr_fd;
guint i;
info = g_new0 (BackupSaveInfo, 1);
@@ -477,19 +478,35 @@ tracker_data_backup_save (GFile *destination,
/* It's fine to untar this asynchronous: the journal replay code can or
* should cope with unfinished entries at the end of the file, while
* restoring a backup made this way. */
-
- if (!tracker_spawn_async_with_channels ((const gchar **) argv,
- 0, &pid,
- &stdin_channel,
- &stdout_channel,
- &stderr_channel)) {
+ result = g_spawn_async_with_pipes (NULL, /* working dir */
+ (gchar **) argv,
+ NULL, /* env */
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, /* func to call before exec() */
+ 0,
+ &pid,
+ &stdin_fd,
+ &stdout_fd,
+ &stderr_fd,
+ &local_error);
+
+ if (!result || local_error) {
GError *error = NULL;
- g_set_error (&error, TRACKER_DATA_BACKUP_ERROR,
+
+ g_set_error (&error,
+ TRACKER_DATA_BACKUP_ERROR,
TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
- "Error starting tar program");
+ "%s, %s",
+ _("Error starting 'tar' program"),
+ local_error ? local_error->message : _("No error given"));
+
+ g_warning ("%s", error->message);
+
on_journal_copied (info, error);
+
g_strfreev (argv);
- g_error_free (error);
+ g_clear_error (&local_error);
+
return;
}
@@ -497,14 +514,14 @@ tracker_data_backup_save (GFile *destination,
context->lines = NULL;
context->data = info;
context->pid = pid;
- context->stdin_channel = stdin_channel;
- context->stdout_channel = stdout_channel;
- context->stderr_channel = stderr_channel;
- context->stdout_watch_id = g_io_add_watch (stdout_channel,
+ context->stdin_channel = g_io_channel_unix_new (stdin_fd);
+ context->stdout_channel = g_io_channel_unix_new (stdout_fd);
+ context->stderr_channel = g_io_channel_unix_new (stderr_fd);
+ context->stdout_watch_id = g_io_add_watch (context->stdout_channel,
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
read_line_of_tar_output,
context);
- context->stderr_watch_id = g_io_add_watch (stderr_channel,
+ context->stderr_watch_id = g_io_add_watch (context->stderr_channel,
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
read_error_of_tar_output,
context);
@@ -560,6 +577,7 @@ tracker_data_backup_restore (GFile *journal,
gchar *tmp_stdout = NULL;
gchar *tmp_stderr = NULL;
gchar **argv;
+ gboolean result;
gint exit_status;
#endif /* DISABLE_JOURNAL */
@@ -581,26 +599,40 @@ tracker_data_backup_restore (GFile *journal,
g_object_unref (parent);
/* Synchronous: we don't want the mainloop to run while copying the
- * journal, as nobody should be writing anything at this point */
-
- if (!tracker_spawn (argv, 0, &tmp_stdout, &tmp_stderr, &exit_status)) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ * journal, as nobody should be writing anything at this point
+ */
+ result = g_spawn_sync (NULL, /* working dir */
+ argv,
+ NULL, /* env */
+ G_SPAWN_SEARCH_PATH,
+ NULL,
+ 0, /* timeout */
+ &tmp_stdout,
+ &tmp_stderr,
+ &exit_status,
+ &n_error);
+
+ if (!result || n_error) {
+ g_set_error (&info->error,
+ TRACKER_DATA_BACKUP_ERROR,
TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
- "Error starting tar program");
- }
-
- if (!info->error && tmp_stderr) {
- if (strlen (tmp_stderr) > 0) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
- TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
- "%s", tmp_stderr);
- }
- }
-
- if (!info->error && exit_status != 0) {
- g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,
+ "%s, %s",
+ _("Error starting 'tar' program"),
+ n_error ? n_error->message : _("No error given"));
+ g_warning ("%s", info->error->message);
+ g_clear_error (&n_error);
+ } else if (tmp_stderr && strlen (tmp_stderr) > 0) {
+ g_set_error (&info->error,
+ TRACKER_DATA_BACKUP_ERROR,
+ TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
+ "%s",
+ tmp_stderr);
+ } else if (exit_status != 0) {
+ g_set_error (&info->error,
+ TRACKER_DATA_BACKUP_ERROR,
TRACKER_DATA_BACKUP_ERROR_UNKNOWN,
- "Unknown error, tar exited with exit status %d", exit_status);
+ _("Unknown error, 'tar' exited with status %d"),
+ exit_status);
}
g_free (tmp_stderr);
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index 1f26ae0..c397c4f 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -119,6 +119,17 @@ static TransactionFormat current_transaction_format;
static gboolean tracker_db_journal_rotate (GError **error);
+#ifndef HAVE_STRNLEN
+
+size_t
+strnlen (const char *str, size_t max)
+{
+ const char *end = memchr (str, 0, max);
+ return end ? (size_t)(end - str) : max;
+}
+
+#endif /* HAVE_STRNLEN */
+
static gboolean
journal_eof (JournalReader *jreader)
{
diff --git a/src/tracker-control/tracker-control-general.c b/src/tracker-control/tracker-control-general.c
index fc6aa91..b69b4c6 100644
--- a/src/tracker-control/tracker-control-general.c
+++ b/src/tracker-control/tracker-control-general.c
@@ -21,7 +21,7 @@
#include <errno.h>
-#include <glib.h>
+#include <glib/gstdio.h>
#include <glib/gi18n.h>
#ifdef __sun
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index ced5ef0..a04a9c0 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -52,8 +52,7 @@ rules_files = \
90-text-generic.rule \
90-libav-audio-generic.rule \
90-libav-video-generic.rule \
- 91-gstreamer-generic-dlna.rule \
- 93-mplayer-generic.rule
+ 91-gstreamer-generic-dlna.rule
# NOTE:
# We don't always link with libtracker-common, we only link
@@ -129,11 +128,6 @@ if HAVE_GUPNP_DLNA
rules_DATA += 91-gstreamer-generic-dlna.rule
endif
-if USING_EXTERNAL_GENERIC_MEDIA_PLAYER
-extractmodules_LTLIBRARIES += libextract-mplayer.la
-rules_DATA += 93-mplayer-generic.rule
-endif
-
if HAVE_TOTEM_PL_PARSER
extractmodules_LTLIBRARIES += libextract-playlist.la
rules_DATA += 15-playlist.rule
@@ -234,16 +228,6 @@ libextract_flac_la_LIBADD = \
$(TRACKER_EXTRACT_MODULES_LIBS) \
$(LIBFLAC_LIBS)
-# MPlayer
-libextract_mplayer_la_SOURCES = tracker-extract-mplayer.c
-libextract_mplayer_la_CFLAGS = $(TRACKER_EXTRACT_MODULES_CFLAGS)
-libextract_mplayer_la_LDFLAGS = $(module_flags)
-libextract_mplayer_la_LIBADD = \
- $(top_builddir)/src/libtracker-extract/libtracker-extract.la \
- $(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(BUILD_LIBS) \
- $(TRACKER_EXTRACT_MODULES_LIBS)
-
# Oasis
libextract_oasis_la_SOURCES = tracker-extract-oasis.c
libextract_oasis_la_CFLAGS = \
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 290d210..f2ef306 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -435,6 +435,17 @@ static gint spf_table[6] = {
48, 144, 144, 48, 144, 72
};
+#ifndef HAVE_STRNLEN
+
+size_t
+strnlen (const char *str, size_t max)
+{
+ const char *end = memchr (str, 0, max);
+ return end ? (size_t)(end - str) : max;
+}
+
+#endif /* HAVE_STRNLEN */
+
static void
id3tag_free (id3tag *tags)
{
diff --git a/src/tracker-extract/tracker-extract-msoffice-xml.c
b/src/tracker-extract/tracker-extract-msoffice-xml.c
index f9892f9..71155be 100644
--- a/src/tracker-extract/tracker-extract-msoffice-xml.c
+++ b/src/tracker-extract/tracker-extract-msoffice-xml.c
@@ -32,9 +32,6 @@
#include <gsf/gsf-utils.h>
#include <gsf/gsf-infile-zip.h>
-#include <libtracker-common/tracker-utils.h>
-#include <libtracker-common/tracker-os-dependant.h>
-
#include <libtracker-extract/tracker-extract.h>
#include "tracker-main.h"
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index da183ef..83693de 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -25,7 +25,6 @@
#include <string.h>
#include <glib.h>
-
#include <gsf/gsf.h>
#include <gsf/gsf-doc-meta-data.h>
#include <gsf/gsf-infile.h>
@@ -35,10 +34,7 @@
#include <gsf/gsf-utils.h>
#include <gsf/gsf-infile-zip.h>
-#include <libtracker-common/tracker-utils.h>
-#include <libtracker-common/tracker-file-utils.h>
-#include <libtracker-common/tracker-os-dependant.h>
-
+#include <libtracker-common/tracker-common.h>
#include <libtracker-extract/tracker-extract.h>
#include "tracker-main.h"
diff --git a/src/tracker-extract/tracker-extract-oasis.c b/src/tracker-extract/tracker-extract-oasis.c
index 658b140..a580b72 100644
--- a/src/tracker-extract/tracker-extract-oasis.c
+++ b/src/tracker-extract/tracker-extract-oasis.c
@@ -18,7 +18,9 @@
* Boston, MA 02110-1301, USA.
*/
-#include <libtracker-common/tracker-os-dependant.h>
+#include "config.h"
+
+#include <libtracker-common/tracker-common.h>
#include <libtracker-extract/tracker-extract.h>
diff --git a/src/tracker-extract/tracker-extract-ps.c b/src/tracker-extract/tracker-extract-ps.c
index 6556a2e..f9580e9 100644
--- a/src/tracker-extract/tracker-extract-ps.c
+++ b/src/tracker-extract/tracker-extract-ps.c
@@ -29,9 +29,7 @@
#include <glib.h>
#include <glib/gstdio.h>
-#include <libtracker-common/tracker-os-dependant.h>
-#include <libtracker-common/tracker-file-utils.h>
-
+#include <libtracker-common/tracker-common.h>
#include <libtracker-extract/tracker-extract.h>
static gchar *
@@ -217,6 +215,45 @@ extract_ps (const gchar *uri,
#ifdef USING_UNZIPPSFILES
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+static void
+spawn_child_func (gpointer user_data)
+{
+ struct rlimit cpu_limit;
+ gint timeout = GPOINTER_TO_INT (user_data);
+
+ if (timeout > 0) {
+ /* set cpu limit */
+ getrlimit (RLIMIT_CPU, &cpu_limit);
+ cpu_limit.rlim_cur = timeout;
+ cpu_limit.rlim_max = timeout + 1;
+
+ if (setrlimit (RLIMIT_CPU, &cpu_limit) != 0) {
+ g_critical ("Failed to set resource limit for CPU");
+ }
+
+ /* Have this as a precaution in cases where cpu limit has not
+ * been reached due to spawned app sleeping.
+ */
+ alarm (timeout + 2);
+ }
+
+ /* Set child's niceness to 19 */
+ errno = 0;
+
+ /* nice() uses attribute "warn_unused_result" and so complains
+ * if we do not check its returned value. But it seems that
+ * since glibc 2.2.4, nice() can return -1 on a successful call
+ * so we have to check value of errno too. Stupid...
+ */
+ if (nice (19) == -1 && errno) {
+ g_warning ("Failed to set nice value");
+ }
+}
+
static void
extract_ps_gz (const gchar *uri,
TrackerSparqlBuilder *preupdate,
@@ -242,7 +279,7 @@ extract_ps_gz (const gchar *uri,
(gchar **) argv,
NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
- tracker_spawn_child_func,
+ spawn_child_func,
GINT_TO_POINTER (10),
NULL,
NULL,
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index d9788a5..91645bd 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -22,7 +22,7 @@
#include <string.h>
#include <locale.h>
-#include <glib.h>
+#include <glib/gstdio.h>
#include <gio/gio.h>
#include <libtracker-common/tracker-common.h>
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 4ecec72..8d045ce 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -22,7 +22,7 @@
#include <string.h>
#include <locale.h>
-#include <glib.h>
+#include <glib/gstdio.h>
#include <gio/gio.h>
#include <libtracker-common/tracker-common.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]