tracker r1363 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1363 - in branches/indexer-split: . src/trackerd
- Date: Wed, 7 May 2008 14:20:06 +0100 (BST)
Author: mr
Date: Wed May 7 13:20:06 2008
New Revision: 1363
URL: http://svn.gnome.org/viewvc/tracker?rev=1363&view=rev
Log:
* src/trackerd/tracker-utils.[ch]:
* src/trackerd/tracker-xesam-session.c:
* src/trackerd/tracker-xesam.[ch]: Moved tracker_unique_key() here
from tracker-utils since it is an xesam thing only at the moment.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-utils.c
branches/indexer-split/src/trackerd/tracker-utils.h
branches/indexer-split/src/trackerd/tracker-xesam-session.c
branches/indexer-split/src/trackerd/tracker-xesam.c
branches/indexer-split/src/trackerd/tracker-xesam.h
Modified: branches/indexer-split/src/trackerd/tracker-utils.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-utils.c (original)
+++ branches/indexer-split/src/trackerd/tracker-utils.c Wed May 7 13:20:06 2008
@@ -914,6 +914,7 @@
tracker_log ("file changes to %s is pausing tracker", uri);
+
tracker->grace_period++;
}
@@ -968,61 +969,3 @@
return tracker_config_get_disable_indexing_on_battery (tracker->config);
}
-gchar*
-tracker_unique_key (void)
-{
- /* This function is hardly cryptographically random but should be
- "good enough" */
- static guint serial = 0;
- gchar* key;
- guint t, ut, p, u, r;
- GTimeVal tv;
-
- g_get_current_time(&tv);
-
- t = tv.tv_sec;
- ut = tv.tv_usec;
-
- p = getpid();
-
- #ifdef HAVE_GETUID
- u = getuid();
- #else
- u = 0;
- #endif
-
- /* don't bother to seed; if it's based on the time or any other
- changing info we can get, we may as well just use that changing
- info. since we don't seed we'll at least get a different number
- on every call to this function in the same executable. */
- r = rand();
-
- /* The letters may increase uniqueness by preventing "melds"
- i.e. 01t01k01 and 0101t0k1 are not the same */
- key = g_strdup_printf("%ut%uut%uu%up%ur%uk%u",
- /* Duplicate keys must be generated
- by two different program instances */
- serial,
- /* Duplicate keys must be generated
- in the same microsecond */
- t,
- ut,
- /* Duplicate keys must be generated by
- the same user */
- u,
- /* Duplicate keys must be generated by
- two programs that got the same PID */
- p,
- /* Duplicate keys must be generated with the
- same random seed and the same index into
- the series of pseudorandom values */
- r,
- /* Duplicate keys must result from running
- this function at the same stack location */
- GPOINTER_TO_UINT(&key));
-
- ++serial;
-
- return key;
-}
-
Modified: branches/indexer-split/src/trackerd/tracker-utils.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-utils.h (original)
+++ branches/indexer-split/src/trackerd/tracker-utils.h Wed May 7 13:20:06 2008
@@ -341,7 +341,6 @@
void tracker_scan_directory (const gchar *uri);
gboolean tracker_low_diskspace (void);
-gchar* tracker_unique_key (void);
gboolean tracker_should_pause (void);
gboolean tracker_should_pause_on_battery (void);
Modified: branches/indexer-split/src/trackerd/tracker-xesam-session.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam-session.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam-session.c Wed May 7 13:20:06 2008
@@ -374,7 +374,7 @@
// todo: parse the query and pass the parsed query or throw an error
search = tracker_xesam_live_search_new (query_xml);
- tracker_xesam_live_search_set_id (search, tracker_unique_key ());
+ tracker_xesam_live_search_set_id (search, tracker_xesam_generate_unique_key ());
g_hash_table_insert (priv->searches,
g_strdup (tracker_xesam_live_search_get_id (search)),
Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c Wed May 7 13:20:06 2008
@@ -19,9 +19,13 @@
* Boston, MA 02110-1301, USA.
*/
-#include "tracker-xesam.h"
+#include <sys/types.h>
+#include <unistd.h>
+
#include <libtracker-common/tracker-config.h>
+#include "tracker-xesam.h"
+
extern Tracker *tracker;
void
@@ -41,7 +45,7 @@
TrackerXesamSession *session;
session = tracker_xesam_session_new ();
- tracker_xesam_session_set_id (session, tracker_unique_key ());
+ tracker_xesam_session_set_id (session, tracker_xesam_generate_unique_key ());
g_hash_table_insert (tracker->xesam_sessions,
g_strdup (tracker_xesam_session_get_id (session)),
@@ -234,4 +238,68 @@
}
}
+gchar *
+tracker_xesam_generate_unique_key (void)
+{
+ static guint serial = 0;
+ gchar *key;
+ guint t, ut, p, u, r;
+ GTimeVal tv;
+
+ /* This function is hardly cryptographically random but should
+ * be "good enough"
+ */
+ g_get_current_time (&tv);
+
+ t = tv.tv_sec;
+ ut = tv.tv_usec;
+
+ p = getpid ();
+
+#ifdef HAVE_GETUID
+ u = getuid ();
+#else
+ u = 0;
+#endif
+
+ /* Don't bother to seed; if it's based on the time or any
+ * other changing info we can get, we may as well just use
+ * that changing info. since we don't seed we'll at least get
+ * a different number on every call to this function in the
+ * same executable.
+ */
+ r = rand ();
+
+ /* The letters may increase uniqueness by preventing "melds"
+ * i.e. 01t01k01 and 0101t0k1 are not the same
+ */
+ key = g_strdup_printf ("%ut%uut%uu%up%ur%uk%u",
+ /* Duplicate keys must be generated by
+ * two different program instances */
+ serial,
+ /* Duplicate keys must be generated in
+ * the same microsecond */
+ t,
+ ut,
+ /* Duplicate keys must be generated by
+ * the same user */
+ u,
+ /* Duplicate keys must be generated by
+ * two programs that got the same PID */
+ p,
+ /* Duplicate keys must be generated with
+ * the same random seed and the same
+ * index into the series of pseudorandom
+ * values */
+ r,
+ /* Duplicate keys must result from
+ * running this function at the same
+ * stack location */
+ GPOINTER_TO_UINT (&key));
+
+ ++serial;
+
+ return key;
+}
+
Modified: branches/indexer-split/src/trackerd/tracker-xesam.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.h Wed May 7 13:20:06 2008
@@ -54,4 +54,6 @@
void tracker_xesam_init (void);
void tracker_xesam_wakeup (guint32 last_id);
+gchar * tracker_xesam_generate_unique_key (void);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]