summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libtracker-common/tracker-file-utils.c6
-rw-r--r--src/libtracker-common/tracker-language.c37
-rw-r--r--src/libtracker-common/tracker-locale.c20
-rw-r--r--src/libtracker-common/tracker-log.c21
-rw-r--r--src/libtracker-common/tracker-os-dependant-unix.c5
-rw-r--r--src/libtracker-data/tracker-db-interface-sqlite.c11
-rw-r--r--src/libtracker-data/tracker-db-journal.c25
-rw-r--r--src/libtracker-data/tracker-db-manager.c23
-rw-r--r--src/libtracker-miner/tracker-thumbnailer.c28
-rw-r--r--src/tracker-extract/tracker-controller.c40
-rw-r--r--src/tracker-extract/tracker-extract.c86
-rw-r--r--src/tracker-writeback/tracker-writeback.c80
-rw-r--r--tests/common/tracker-test-helpers.c4
-rw-r--r--tests/libtracker-extract/tracker-encoding-test.c6
14 files changed, 30 insertions, 362 deletions
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index 09b99f27a..f70925f88 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -363,14 +363,8 @@ tracker_file_system_has_enough_space (const gchar *path,
enough = (remaining >= required_bytes);
if (creating_db) {
-
-#if GLIB_CHECK_VERSION (2,30,0)
str1 = g_format_size (required_bytes);
str2 = g_format_size (remaining);
-#else
- str1 = g_format_size_for_display (required_bytes);
- str2 = g_format_size_for_display (remaining);
-#endif
if (!enough) {
g_critical ("Not enough disk space to create databases, "
diff --git a/src/libtracker-common/tracker-language.c b/src/libtracker-common/tracker-language.c
index 66e389a90..f3d739c3a 100644
--- a/src/libtracker-common/tracker-language.c
+++ b/src/libtracker-common/tracker-language.c
@@ -39,11 +39,7 @@ struct _TrackerLanguagePriv {
gboolean enable_stemmer;
gchar *language_code;
-#if GLIB_CHECK_VERSION (2,31,0)
GMutex stemmer_mutex;
-#else
- GMutex *stemmer_mutex;
-#endif
gpointer stemmer;
};
@@ -138,11 +134,7 @@ tracker_language_init (TrackerLanguage *language)
g_str_equal,
g_free,
NULL);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_init (&priv->stemmer_mutex);
-#else
- priv->stemmer_mutex = g_mutex_new ();
-#endif
stem_language = tracker_language_get_name_by_code (NULL);
priv->stemmer = sb_stemmer_new (stem_language, NULL);
@@ -155,21 +147,12 @@ language_finalize (GObject *object)
priv = GET_PRIV (object);
-#if GLIB_CHECK_VERSION (2,31,0)
if (priv->stemmer) {
g_mutex_lock (&priv->stemmer_mutex);
sb_stemmer_delete (priv->stemmer);
g_mutex_unlock (&priv->stemmer_mutex);
}
g_mutex_clear (&priv->stemmer_mutex);
-#else
- if (priv->stemmer) {
- g_mutex_lock (priv->stemmer_mutex);
- sb_stemmer_delete (priv->stemmer);
- g_mutex_unlock (priv->stemmer_mutex);
- }
- g_mutex_free (priv->stemmer_mutex);
-#endif
if (priv->stop_words) {
g_hash_table_unref (priv->stop_words);
@@ -279,11 +262,7 @@ language_add_stopwords (TrackerLanguage *language,
content = g_mapped_file_get_contents (mapped_file);
words = g_strsplit_set (content, "\n" , -1);
-#if GLIB_CHECK_VERSION(2,22,0)
g_mapped_file_unref (mapped_file);
-#else
- g_mapped_file_free (mapped_file);
-#endif
/* FIXME: Shouldn't clear the hash table first? */
for (p = words; *p; p++) {
@@ -326,11 +305,7 @@ language_set_stopword_list (TrackerLanguage *language,
stem_language = tracker_language_get_name_by_code (language_code);
stem_language_lower = g_ascii_strdown (stem_language, -1);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->stemmer_mutex);
-#else
- g_mutex_lock (priv->stemmer_mutex);
-#endif
if (priv->stemmer) {
sb_stemmer_delete (priv->stemmer);
@@ -342,11 +317,7 @@ language_set_stopword_list (TrackerLanguage *language,
stem_language_lower);
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->stemmer_mutex);
-#else
- g_mutex_unlock (priv->stemmer_mutex);
-#endif
g_free (stem_language_lower);
}
@@ -542,21 +513,13 @@ tracker_language_stem_word (TrackerLanguage *language,
return g_strndup (word, word_length);
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->stemmer_mutex);
-#else
- g_mutex_lock (priv->stemmer_mutex);
-#endif
stem_word = (const gchar*) sb_stemmer_stem (priv->stemmer,
(guchar*) word,
word_length);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->stemmer_mutex);
-#else
- g_mutex_unlock (priv->stemmer_mutex);
-#endif
return g_strdup (stem_word);
}
diff --git a/src/libtracker-common/tracker-locale.c b/src/libtracker-common/tracker-locale.c
index 2463e405c..e2cfab1dd 100644
--- a/src/libtracker-common/tracker-locale.c
+++ b/src/libtracker-common/tracker-locale.c
@@ -46,11 +46,7 @@ static const gchar *locale_names[TRACKER_LOCALE_LAST] = {
/* Already initialized? */
static gboolean initialized;
-#if GLIB_CHECK_VERSION (2,31,0)
static GRecMutex locales_mutex;
-#else
-static GStaticRecMutex locales_mutex = G_STATIC_REC_MUTEX_INIT;
-#endif
const gchar*
tracker_locale_get_name (guint i)
@@ -63,11 +59,7 @@ void
tracker_locale_set (TrackerLocaleID id,
const gchar *value)
{
-#if GLIB_CHECK_VERSION (2,31,0)
g_rec_mutex_lock (&locales_mutex);
-#else
- g_static_rec_mutex_lock (&locales_mutex);
-#endif
if (current_locales[id]) {
g_debug ("Locale '%s' was changed from '%s' to '%s'",
@@ -107,11 +99,7 @@ tracker_locale_set (TrackerLocaleID id,
break;
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_rec_mutex_unlock (&locales_mutex);
-#else
- g_static_rec_mutex_unlock (&locales_mutex);
-#endif
}
void
@@ -178,21 +166,13 @@ tracker_locale_get (TrackerLocaleID id)
g_return_val_if_fail (initialized, NULL);
-#if GLIB_CHECK_VERSION (2,31,0)
g_rec_mutex_lock (&locales_mutex);
-#else
- g_static_rec_mutex_lock (&locales_mutex);
-#endif
/* Always return a duplicated string, as the locale may change at any
* moment */
locale = g_strdup (current_locales[id]);
-#if GLIB_CHECK_VERSION (2,31,0)
g_rec_mutex_unlock (&locales_mutex);
-#else
- g_static_rec_mutex_unlock (&locales_mutex);
-#endif
return locale;
}
diff --git a/src/libtracker-common/tracker-log.c b/src/libtracker-common/tracker-log.c
index 0eadbacf0..b247882fa 100644
--- a/src/libtracker-common/tracker-log.c
+++ b/src/libtracker-common/tracker-log.c
@@ -39,12 +39,7 @@ static FILE *fd;
static gint verbosity;
static guint log_handler_id;
static gboolean use_log_files;
-
-#if GLIB_CHECK_VERSION (2,31,0)
static GMutex mutex;
-#else
-static GMutex *mutex;
-#endif
static inline void
log_output (const gchar *domain,
@@ -62,11 +57,7 @@ log_output (const gchar *domain,
g_return_if_fail (message != NULL && message[0] != '\0');
/* Ensure file logging is thread safe */
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&mutex);
-#else
- g_mutex_lock (mutex);
-#endif
/* Check log size, 10MiB limit */
if (size > (10 << 20) && fd) {
@@ -133,11 +124,7 @@ log_output (const gchar *domain,
g_free (output);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&mutex);
-#else
- g_mutex_unlock (mutex);
-#endif
}
static void
@@ -247,11 +234,7 @@ tracker_log_init (gint this_verbosity,
verbosity = CLAMP (this_verbosity, 0, 3);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_init (&mutex);
-#else
- mutex = g_mutex_new ();
-#endif
switch (this_verbosity) {
/* Log level 3: EVERYTHING */
@@ -318,11 +301,7 @@ tracker_log_shutdown (void)
fclose (fd);
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_clear (&mutex);
-#else
- g_mutex_free (mutex);
-#endif
initialized = FALSE;
}
diff --git a/src/libtracker-common/tracker-os-dependant-unix.c b/src/libtracker-common/tracker-os-dependant-unix.c
index cc5f5fcf8..24108f446 100644
--- a/src/libtracker-common/tracker-os-dependant-unix.c
+++ b/src/libtracker-common/tracker-os-dependant-unix.c
@@ -335,13 +335,8 @@ tracker_memory_setrlimits (void)
} else {
gchar *str1, *str2;
-#if GLIB_CHECK_VERSION (2,30,0)
str1 = g_format_size (total);
str2 = g_format_size (limit);
-#else
- str1 = g_format_size_for_display (total);
- str2 = g_format_size_for_display (limit);
-#endif
g_message ("Setting memory limitations: total is %s, minimum is 256 MB, recommended is ~1 GB", str1);
g_message (" Virtual/Heap set to %s (50%% of total or MAXLONG)", str2);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index c388e178b..a9e899e31 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -52,13 +52,6 @@
#include "tracker-db-interface-sqlite.h"
#include "tracker-db-manager.h"
-/* Since 2.30, g_atomic_int_add() is fully equivalente to g_atomic_int_exchange_and_add() */
-#if GLIB_CHECK_VERSION (2,30,0)
-#define ATOMIC_EXCHANGE_AND_ADD(a,v) g_atomic_int_add (a,v)
-#else
-#define ATOMIC_EXCHANGE_AND_ADD(a,v) g_atomic_int_exchange_and_add (a,v)
-#endif
-
#define UNKNOWN_STATUS 0.5
typedef struct {
@@ -1494,7 +1487,7 @@ execute_stmt (TrackerDBInterface *interface,
/* Statement is going to start, check if we got a request to reset the
* collator, and if so, do it. */
- if (ATOMIC_EXCHANGE_AND_ADD (&interface->n_active_cursors, 1) == 0 &&
+ if (g_atomic_int_add (&interface->n_active_cursors, 1) == 0 &&
g_atomic_int_compare_and_exchange (&(interface->collator_reset_requested), TRUE, FALSE)) {
tracker_db_interface_sqlite_reset_collator (interface);
}
@@ -1871,7 +1864,7 @@ tracker_db_cursor_sqlite_new (sqlite3_stmt *sqlite_stmt,
/* As soon as we create a cursor, check if we need a collator reset
* and notify the iface about the new cursor */
iface = ref_stmt->db_interface;
- if (ATOMIC_EXCHANGE_AND_ADD (&iface->n_active_cursors, 1) == 0 &&
+ if (g_atomic_int_add (&iface->n_active_cursors, 1) == 0 &&
g_atomic_int_compare_and_exchange (&(iface->collator_reset_requested), TRUE, FALSE)) {
tracker_db_interface_sqlite_reset_collator (iface);
}
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index a66467509..fbb1612f1 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -120,9 +120,7 @@ static JournalWriter ontology_writer = {0};
static TransactionFormat current_transaction_format;
-#if GLIB_CHECK_VERSION (2, 24, 2)
static gboolean tracker_db_journal_rotate (GError **error);
-#endif /* GLib check */
static gboolean
journal_eof (JournalReader *jreader)
@@ -404,7 +402,7 @@ write_all_data (int fd,
while (len > 0) {
written = write (fd, data, len);
-
+
if (written < 0) {
gint err = errno;
@@ -426,7 +424,7 @@ write_all_data (int fd,
return FALSE;
}
-
+
len -= written;
data += written;
}
@@ -1202,13 +1200,11 @@ tracker_db_journal_commit_db_transaction (GError **error)
} else {
ret = db_journal_writer_commit_db_transaction (&writer, &n_error);
-#if GLIB_CHECK_VERSION (2, 24, 2)
if (ret) {
if (rotating_settings.do_rotating && (writer.cur_size > rotating_settings.chunk_size)) {
ret = tracker_db_journal_rotate (&n_error);
}
}
-#endif /* GLib check */
}
if (n_error) {
@@ -1290,7 +1286,6 @@ db_journal_reader_init_file (JournalReader *jreader,
const gchar *filename,
GError **error)
{
-#if GLIB_CHECK_VERSION (2, 24, 2)
if (g_str_has_suffix (filename, ".gz")) {
GFile *file;
GInputStream *stream, *cstream;
@@ -1319,7 +1314,6 @@ db_journal_reader_init_file (JournalReader *jreader,
jreader->stream = g_data_input_stream_new (cstream);
g_object_unref (cstream);
} else {
-#endif /* GLib check */
jreader->file = g_mapped_file_new (filename, FALSE, error);
if (!jreader->file) {
@@ -1330,9 +1324,7 @@ db_journal_reader_init_file (JournalReader *jreader,
g_mapped_file_get_contents (jreader->file);
jreader->end = jreader->current + g_mapped_file_get_length (jreader->file);
-#if GLIB_CHECK_VERSION (2, 24, 2)
}
-#endif /* GLib check */
if (!journal_verify_header (jreader)) {
g_set_error (error, TRACKER_DB_JOURNAL_ERROR,
@@ -1509,12 +1501,7 @@ db_journal_reader_shutdown (JournalReader *jreader)
jreader->underlying_stream_info = NULL;
}
} else if (jreader->file) {
-#if GLIB_CHECK_VERSION(2,22,0)
g_mapped_file_unref (jreader->file);
-#else
- g_mapped_file_free (jreader->file);
-#endif
-
jreader->file = NULL;
}
@@ -1579,7 +1566,7 @@ db_journal_reader_next (JournalReader *jreader, gboolean global_reader, GError *
* [magic]
* [version]
* [
- * [entry
+ * [entry
* [size]
* [amount]
* [crc]
@@ -1884,7 +1871,7 @@ tracker_db_journal_reader_verify_last (const gchar *filename,
if (jreader.end - entry_size_check < jreader.current) {
g_set_error (error, TRACKER_DB_JOURNAL_ERROR,
- TRACKER_DB_JOURNAL_ERROR_DAMAGED_JOURNAL_ENTRY,
+ TRACKER_DB_JOURNAL_ERROR_DAMAGED_JOURNAL_ENTRY,
"Damaged journal entry at end of journal");
db_journal_reader_shutdown (&jreader);
return FALSE;
@@ -2056,7 +2043,6 @@ tracker_db_journal_reader_get_progress (void)
return ret;
}
-#if GLIB_CHECK_VERSION (2, 24, 2)
static void
on_chunk_copied_delete (GObject *source_object,
GAsyncResult *res,
@@ -2121,7 +2107,7 @@ tracker_db_journal_rotate (GError **error)
ptr = f_name + strlen (TRACKER_DB_JOURNAL_FILENAME ".");
cur = atoi (ptr);
max = MAX (cur, max);
- }
+ }
f_name = g_dir_read_name (journal_dir);
}
@@ -2185,7 +2171,6 @@ tracker_db_journal_rotate (GError **error)
return ret;
}
-#endif /* GLib check */
#else /* DISABLE_JOURNAL */
void
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index f989af793..4ec6454af 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -162,11 +162,7 @@ static TrackerDBManagerFlags old_flags = 0;
static guint s_cache_size;
static guint u_cache_size;
-#if GLIB_CHECK_VERSION (2,31,0)
static GPrivate interface_data_key = G_PRIVATE_INIT ((GDestroyNotify)g_object_unref);
-#else
-static GStaticPrivate interface_data_key = G_STATIC_PRIVATE_INIT;
-#endif
/* mutex used by singleton connection in libtracker-direct, not used by tracker-store */
static GMutex global_mutex;
@@ -1244,13 +1240,8 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
s_cache_size = select_cache_size;
u_cache_size = update_cache_size;
- if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
-#if GLIB_CHECK_VERSION (2,31,0)
+ if ((flags & TRACKER_DB_MANAGER_READONLY) == 0)
g_private_replace (&interface_data_key, resources_iface);
-#else
- g_static_private_set (&interface_data_key, resources_iface, (GDestroyNotify) g_object_unref);
-#endif
- }
return TRUE;
}
@@ -1288,11 +1279,7 @@ tracker_db_manager_shutdown (void)
}
/* shutdown db interface in all threads */
-#if GLIB_CHECK_VERSION (2,31,0)
g_private_replace (&interface_data_key, NULL);
-#else
- g_static_private_free (&interface_data_key);
-#endif
/* Since we don't reference this enum anywhere, we do
* it here to make sure it exists when we call
@@ -1502,11 +1489,7 @@ tracker_db_manager_get_db_interface (void)
return global_iface;
}
-#if GLIB_CHECK_VERSION (2,31,0)
interface = g_private_get (&interface_data_key);
-#else
- interface = g_static_private_get (&interface_data_key);
-#endif
/* Ensure the interface is there */
if (!interface) {
@@ -1529,11 +1512,7 @@ tracker_db_manager_get_db_interface (void)
TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE,
u_cache_size);
-#if GLIB_CHECK_VERSION (2,31,0)
g_private_set (&interface_data_key, interface);
-#else
- g_static_private_set (&interface_data_key, interface, (GDestroyNotify)g_object_unref);
-#endif
}
return interface;
diff --git a/src/libtracker-miner/tracker-thumbnailer.c b/src/libtracker-miner/tracker-thumbnailer.c
index 9ff7e3df8..3ad5a2d55 100644
--- a/src/libtracker-miner/tracker-thumbnailer.c
+++ b/src/libtracker-miner/tracker-thumbnailer.c
@@ -63,12 +63,8 @@ typedef struct {
gboolean service_is_available;
} TrackerThumbnailerPrivate;
-#if GLIB_CHECK_VERSION (2,31,0)
static void private_free (gpointer data);
static GPrivate private_key = G_PRIVATE_INIT (private_free);
-#else
-static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
-#endif
static void
private_free (gpointer data)
@@ -146,11 +142,7 @@ tracker_thumbnailer_init (void)
/* Don't start at 0, start at 1. */
private->request_id = 1;
-#if GLIB_CHECK_VERSION (2,31,0)
g_private_replace (&private_key, private);
-#else
- g_static_private_set (&private_key, private, private_free);
-#endif
g_message ("Thumbnailer connections being set up...");
@@ -276,11 +268,7 @@ error_handler:
void
tracker_thumbnailer_shutdown (void)
{
-#if GLIB_CHECK_VERSION (2,31,0)
g_private_replace (&private_key, NULL);
-#else
- g_static_private_set (&private_key, NULL, NULL);
-#endif
}
/**
@@ -309,11 +297,7 @@ tracker_thumbnailer_move_add (const gchar *from_uri,
g_return_val_if_fail (from_uri != NULL, FALSE);
g_return_val_if_fail (to_uri != NULL, FALSE);
-#if GLIB_CHECK_VERSION (2,31,0)
private = g_private_get (&private_key);
-#else
- private = g_static_private_get (&private_key);
-#endif
g_return_val_if_fail (private != NULL, FALSE);
if (!private->service_is_available) {
@@ -356,11 +340,7 @@ tracker_thumbnailer_remove_add (const gchar *uri,
g_return_val_if_fail (uri != NULL, FALSE);
-#if GLIB_CHECK_VERSION (2,31,0)
private = g_private_get (&private_key);
-#else
- private = g_static_private_get (&private_key);
-#endif
g_return_val_if_fail (private != NULL, FALSE);
if (!private->service_is_available) {
@@ -395,11 +375,7 @@ tracker_thumbnailer_cleanup (const gchar *uri_prefix)
g_return_val_if_fail (uri_prefix != NULL, FALSE);
-#if GLIB_CHECK_VERSION (2,31,0)
private = g_private_get (&private_key);
-#else
- private = g_static_private_get (&private_key);
-#endif
g_return_val_if_fail (private != NULL, FALSE);
if (!private->service_is_available) {
@@ -437,11 +413,7 @@ tracker_thumbnailer_send (void)
TrackerThumbnailerPrivate *private;
guint list_len;
-#if GLIB_CHECK_VERSION (2,31,0)
private = g_private_get (&private_key);
-#else
- private = g_static_private_get (&private_key);
-#endif
g_return_if_fail (private != NULL);
if (!private->service_is_available) {
diff --git a/src/tracker-extract/tracker-controller.c b/src/tracker-extract/tracker-controller.c
index 2d01246e2..119b040b0 100644
--- a/src/tracker-extract/tracker-controller.c
+++ b/src/tracker-extract/tracker-controller.c
@@ -61,13 +61,8 @@ struct TrackerControllerPrivate {
GError *initialization_error;
-#if GLIB_CHECK_VERSION (2,31,0)
GCond initialization_cond;
GMutex initialization_mutex;
-#else
- GCond *initialization_cond;
- GMutex *initialization_mutex;
-#endif
guint initialized : 1;
};
@@ -172,13 +167,8 @@ tracker_controller_finalize (GObject *object)
g_main_loop_unref (priv->main_loop);
g_main_context_unref (priv->context);
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_clear (&priv->initialization_cond);
g_mutex_clear (&priv->initialization_mutex);
-#else
- g_cond_free (priv->initialization_cond);
- g_mutex_free (priv->initialization_mutex);
-#endif
G_OBJECT_CLASS (tracker_controller_parent_class)->finalize (object);
}
@@ -411,13 +401,8 @@ tracker_controller_init (TrackerController *controller)
g_signal_connect (priv->storage, "mount-point-removed",
G_CALLBACK (mount_point_removed_cb), controller);
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_init (&priv->initialization_cond);
g_mutex_init (&priv->initialization_mutex);
-#else
- priv->initialization_cond = g_cond_new ();
- priv->initialization_mutex = g_mutex_new ();
-#endif
}
static void
@@ -778,23 +763,14 @@ controller_notify_main_thread (TrackerController *controller,
priv = controller->priv;
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->initialization_mutex);
-#else
- g_mutex_lock (priv->initialization_mutex);
-#endif
priv->initialized = TRUE;
priv->initialization_error = error;
/* Notify about the initialization */
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_signal (&priv->initialization_cond);
g_mutex_unlock (&priv->initialization_mutex);
-#else
- g_cond_signal (priv->initialization_cond);
- g_mutex_unlock (priv->initialization_mutex);
-#endif
}
static void
@@ -984,8 +960,6 @@ tracker_controller_start (TrackerController *controller,
GError **error)
{
TrackerControllerPrivate *priv;
-
-#if GLIB_CHECK_VERSION (2,31,0)
GThread *thread;
thread = g_thread_try_new ("controller",
@@ -997,12 +971,6 @@ tracker_controller_start (TrackerController *controller,
/* We don't want to join it, so just unref the GThread */
g_thread_unref (thread);
-#else
- if (!g_thread_create (tracker_controller_thread_func,
- controller, FALSE, error)) {
- return FALSE;
- }
-#endif
priv = controller->priv;
@@ -1012,18 +980,10 @@ tracker_controller_start (TrackerController *controller,
#endif /* THREAD_ENABLE_TRACE */
/* Wait for the controller thread to notify initialization */
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->initialization_mutex);
while (!priv->initialized)
g_cond_wait (&priv->initialization_cond, &priv->initialization_mutex);
g_mutex_unlock (&priv->initialization_mutex);
-#else
- g_mutex_lock (priv->initialization_mutex);
- while (!priv->initialized) {
- g_cond_wait (priv->initialization_cond, priv->initialization_mutex);
- }
- g_mutex_unlock (priv->initialization_mutex);
-#endif
/* If there was any error resulting from initialization, propagate it */
if (priv->initialization_error != NULL) {
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 91b1d3254..58de1b1cb 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -61,11 +61,7 @@ typedef struct {
/* used to maintain the running tasks
* and stats from different threads
*/
-#if GLIB_CHECK_VERSION (2,31,0)
GMutex task_mutex;
-#else
- GMutex *task_mutex;
-#endif
/* Thread pool for multi-threaded extractors */
GThreadPool *thread_pool;
@@ -144,11 +140,7 @@ tracker_extract_init (TrackerExtract *object)
priv->thread_pool = g_thread_pool_new ((GFunc) get_metadata,
NULL, 10, TRUE, NULL);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_init (&priv->task_mutex);
-#else
- priv->task_mutex = g_mutex_new ();
-#endif
}
static void
@@ -173,11 +165,7 @@ tracker_extract_finalize (GObject *object)
g_hash_table_destroy (priv->statistics_data);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_clear (&priv->task_mutex);
-#else
- g_mutex_free (priv->task_mutex);
-#endif
G_OBJECT_CLASS (tracker_extract_parent_class)->finalize (object);
}
@@ -191,11 +179,7 @@ report_statistics (GObject *object)
priv = TRACKER_EXTRACT_GET_PRIVATE (object);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->task_mutex);
-#else
- g_mutex_lock (priv->task_mutex);
-#endif
g_message ("--------------------------------------------------");
g_message ("Statistics:");
@@ -228,11 +212,7 @@ report_statistics (GObject *object)
g_message ("--------------------------------------------------");
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->task_mutex);
-#else
- g_mutex_unlock (priv->task_mutex);
-#endif
}
TrackerExtract *
@@ -273,11 +253,7 @@ notify_task_finish (TrackerExtractTask *task,
/* Reports and ongoing tasks may be
* accessed from other threads.
*/
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->task_mutex);
-#else
- g_mutex_lock (priv->task_mutex);
-#endif
stats_data = g_hash_table_lookup (priv->statistics_data,
task->cur_module);
@@ -297,11 +273,7 @@ notify_task_finish (TrackerExtractTask *task,
priv->running_tasks = g_list_remove (priv->running_tasks, task);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->task_mutex);
-#else
- g_mutex_unlock (priv->task_mutex);
-#endif
}
static gboolean
@@ -411,11 +383,7 @@ task_cancellable_cancelled_cb (GCancellable *cancellable,
extract = task->extract;
priv = TRACKER_EXTRACT_GET_PRIVATE (extract);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->task_mutex);
-#else
- g_mutex_lock (priv->task_mutex);
-#endif
if (g_list_find (priv->running_tasks, task)) {
g_message ("Cancelled task for '%s' was currently being "
@@ -424,11 +392,7 @@ task_cancellable_cancelled_cb (GCancellable *cancellable,
_exit (0);
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->task_mutex);
-#else
- g_mutex_unlock (priv->task_mutex);
-#endif
}
static TrackerExtractTask *
@@ -695,15 +659,9 @@ dispatch_task_cb (TrackerExtractTask *task)
return FALSE;
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->task_mutex);
priv->running_tasks = g_list_prepend (priv->running_tasks, task);
g_mutex_unlock (&priv->task_mutex);
-#else
- g_mutex_lock (priv->task_mutex);
- priv->running_tasks = g_list_prepend (priv->running_tasks, task);
- g_mutex_unlock (priv->task_mutex);
-#endif
switch (thread_awareness) {
case TRACKER_MODULE_NONE:
@@ -720,56 +678,38 @@ dispatch_task_cb (TrackerExtractTask *task)
g_message ("Dispatching '%s' in main thread", task->file);
get_metadata (task);
break;
- case TRACKER_MODULE_SINGLE_THREAD:
- {
+ case TRACKER_MODULE_SINGLE_THREAD: {
GAsyncQueue *async_queue;
async_queue = g_hash_table_lookup (priv->single_thread_extractors, module);
if (!async_queue) {
+ GThread *thread;
+
/* No thread created yet for this module, create it
* together with the async queue used to pass data to it
*/
async_queue = g_async_queue_new ();
-
-#if GLIB_CHECK_VERSION (2,31,0)
- {
- GThread *thread;
-
- thread = g_thread_try_new ("single",
- (GThreadFunc) single_thread_get_metadata,
- g_async_queue_ref (async_queue),
- &error);
- if (!thread) {
- g_simple_async_result_take_error ((GSimpleAsyncResult *) task->res, error);
- g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res);
- extract_task_free (task);
- return FALSE;
- }
- /* We won't join the thread, so just unref it here */
- g_object_unref (thread);
- }
-#else
- g_thread_create ((GThreadFunc) single_thread_get_metadata,
- g_async_queue_ref (async_queue),
- FALSE, &error);
-
- if (error) {
- g_simple_async_result_set_from_error ((GSimpleAsyncResult *) task->res, error);
+ thread = g_thread_try_new ("single",
+ (GThreadFunc) single_thread_get_metadata,
+ g_async_queue_ref (async_queue),
+ &error);
+ if (!thread) {
+ g_simple_async_result_take_error ((GSimpleAsyncResult *) task->res, error);
g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res);
extract_task_free (task);
- g_error_free (error);
-
return FALSE;
}
-#endif
+
+ /* We won't join the thread, so just unref it here */
+ g_object_unref (thread);
g_hash_table_insert (priv->single_thread_extractors, module, async_queue);
}
g_async_queue_push (async_queue, task);
- }
break;
+ }
case TRACKER_MODULE_MULTI_THREAD:
/* Put task in thread pool */
g_message ("Dispatching '%s' in thread pool", task->file);
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index bbf629d1a..7435b0fbe 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -63,13 +63,8 @@ typedef struct {
guint shutdown_timeout;
GSource *shutdown_source;
-#if GLIB_CHECK_VERSION (2,31,0)
GCond initialization_cond;
GMutex initialization_mutex, mutex;
-#else
- GCond *initialization_cond;
- GMutex *initialization_mutex, *mutex;
-#endif
GError *initialization_error;
guint initialized : 1;
@@ -152,15 +147,9 @@ tracker_controller_finalize (GObject *object)
g_main_loop_unref (priv->main_loop);
g_main_context_unref (priv->context);
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_clear (&priv->initialization_cond);
g_mutex_clear (&priv->initialization_mutex);
g_mutex_clear (&priv->mutex);
-#else
- g_cond_free (priv->initialization_cond);
- g_mutex_free (priv->initialization_mutex);
- g_mutex_free (priv->mutex);
-#endif
G_OBJECT_CLASS (tracker_controller_parent_class)->finalize (object);
}
@@ -223,11 +212,7 @@ task_cancellable_cancelled_cb (GCancellable *cancellable,
priv = data->controller->priv;
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->mutex);
-#else
- g_mutex_lock (priv->mutex);
-#endif
if (priv->current == data) {
g_message ("Cancelled writeback task for '%s' was currently being "
@@ -236,11 +221,7 @@ task_cancellable_cancelled_cb (GCancellable *cancellable,
_exit (0);
}
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_unlock (&priv->mutex);
-#else
- g_mutex_unlock (priv->mutex);
-#endif
}
@@ -409,15 +390,9 @@ tracker_controller_init (TrackerController *controller)
g_signal_connect (priv->storage, "mount-point-removed",
G_CALLBACK (mount_point_removed_cb), controller);
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_init (&priv->initialization_cond);
g_mutex_init (&priv->initialization_mutex);
g_mutex_init (&priv->mutex);
-#else
- priv->initialization_cond = g_cond_new ();
- priv->initialization_mutex = g_mutex_new ();
- priv->mutex = g_mutex_new ();
-#endif
}
static void
@@ -462,15 +437,9 @@ perform_writeback_cb (gpointer user_data)
tracker_dbus_request_end (data->request, NULL);
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->mutex);
priv->current = NULL;
g_mutex_unlock (&priv->mutex);
-#else
- g_mutex_lock (priv->mutex);
- priv->current = NULL;
- g_mutex_unlock (priv->mutex);
-#endif
writeback_data_free (data);
@@ -508,15 +477,9 @@ io_writeback_job (GTask *task,
gboolean handled = FALSE;
GList *writeback_handlers;
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->mutex);
priv->current = data;
g_mutex_unlock (&priv->mutex);
-#else
- g_mutex_lock (priv->mutex);
- priv->current = data;
- g_mutex_unlock (priv->mutex);
-#endif
writeback_handlers = data->writeback_handlers;
@@ -701,23 +664,14 @@ controller_notify_main_thread (TrackerController *controller,
priv = controller->priv;
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->initialization_mutex);
-#else
- g_mutex_lock (priv->initialization_mutex);
-#endif
priv->initialized = TRUE;
priv->initialization_error = error;
/* Notify about the initialization */
-#if GLIB_CHECK_VERSION (2,31,0)
g_cond_signal (&priv->initialization_cond);
g_mutex_unlock (&priv->initialization_mutex);
-#else
- g_cond_signal (priv->initialization_cond);
- g_mutex_unlock (priv->initialization_mutex);
-#endif
}
static void
@@ -914,6 +868,7 @@ tracker_controller_start (TrackerController *controller,
{
TrackerControllerPrivate *priv;
GList *modules;
+ GThread *thread;
priv = controller->priv;
@@ -938,27 +893,15 @@ tracker_controller_start (TrackerController *controller,
modules = modules->next;
}
-#if GLIB_CHECK_VERSION (2,31,0)
- {
- GThread *thread;
-
- thread = g_thread_try_new ("controller",
- tracker_controller_thread_func,
- controller,
- error);
- if (!thread)
- return FALSE;
-
- /* We don't want to join it, so just unref the GThread */
- g_thread_unref (thread);
- }
-#else
- if (!g_thread_create (tracker_controller_thread_func,
- controller, FALSE, error)) {
+ thread = g_thread_try_new ("controller",
+ tracker_controller_thread_func,
+ controller,
+ error);
+ if (!thread)
return FALSE;
- }
-#endif
+ /* We don't want to join it, so just unref the GThread */
+ g_thread_unref (thread);
#ifdef THREAD_ENABLE_TRACE
g_debug ("Thread:%p (Controller) --- Waiting for controller thread to initialize...",
@@ -966,17 +909,10 @@ tracker_controller_start (TrackerController *controller,
#endif /* THREAD_ENABLE_TRACE */
/* Wait for the controller thread to notify initialization */
-#if GLIB_CHECK_VERSION (2,31,0)
g_mutex_lock (&priv->initialization_mutex);
while (!priv->initialized)
g_cond_wait (&priv->initialization_cond, &priv->initialization_mutex);
g_mutex_unlock (&priv->initialization_mutex);
-#else
- g_mutex_lock (priv->initialization_mutex);
- while (!priv->initialized)
- g_cond_wait (priv->initialization_cond, priv->initialization_mutex);
- g_mutex_unlock (priv->initialization_mutex);
-#endif
/* If there was any error resulting from initialization, propagate it */
if (priv->initialization_error != NULL) {
diff --git a/tests/common/tracker-test-helpers.c b/tests/common/tracker-test-helpers.c
index 793d3a4ea..7517583ca 100644
--- a/tests/common/tracker-test-helpers.c
+++ b/tests/common/tracker-test-helpers.c
@@ -29,11 +29,7 @@ tracker_test_helpers_get_nonutf8 (void)
file = g_mapped_file_new (TEST_TEXT, FALSE, NULL);
nonutf8_str = g_strdup (g_mapped_file_get_contents (file));
nonutf8_str [g_mapped_file_get_length (file) -1] = '\0';
-#if GLIB_CHECK_VERSION(2,22,0)
g_mapped_file_unref (file);
-#else
- g_mapped_file_free (file);
-#endif
}
return nonutf8_str;
diff --git a/tests/libtracker-extract/tracker-encoding-test.c b/tests/libtracker-extract/tracker-encoding-test.c
index a6e458e62..28b97bcc6 100644
--- a/tests/libtracker-extract/tracker-encoding-test.c
+++ b/tests/libtracker-extract/tracker-encoding-test.c
@@ -41,11 +41,7 @@ test_encoding_guessing ()
g_assert_cmpstr (output, ==, "UTF-8");
-#if GLIB_CHECK_VERSION(2,22,0)
g_mapped_file_unref (file);
-#else
- g_mapped_file_free (file);
-#endif
g_free (prefix);
g_free (filen);
@@ -60,7 +56,7 @@ test_encoding_can_guess (void)
g_assert (tracker_encoding_can_guess ());
#else
g_assert (!tracker_encoding_can_guess ());
-#endif
+#endif
}
int