[telepathy-gabble/master] get_local_unix_socket_path: use the channel path to generate the socket path

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Mon Mar 30 07:29:10 PDT 2009


---
 src/ft-channel.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/ft-channel.c b/src/ft-channel.c
index 910e283..3d12a1b 100644
--- a/src/ft-channel.c
+++ b/src/ft-channel.c
@@ -1454,22 +1454,19 @@ static const gchar *
 get_local_unix_socket_path (GabbleFileTransferChannel *self)
 {
   gchar *path = NULL;
-  gint32 random_int;
-  gchar *random_str;
+  gchar *name;
   struct stat buf;
 
-  while (TRUE)
-    {
-      random_int = g_random_int_range (0, G_MAXINT32);
-      random_str = g_strdup_printf ("tp-ft-%i", random_int);
-      path = g_build_filename (gabble_ft_manager_get_tmp_dir (
-            self->priv->connection->ft_manager), random_str, NULL);
-      g_free (random_str);
-
-      if (g_stat (path, &buf) != 0)
-        break;
+  name = g_strdup_printf ("ft-channel-%p", self);
+  path = g_build_filename (gabble_ft_manager_get_tmp_dir (
+        self->priv->connection->ft_manager), name, NULL);
+  g_free (name);
 
-      g_free (path);
+  if (g_stat (path, &buf) == 0)
+    {
+      /* The file is not supposed to exist */
+      DEBUG ("file %s already exists", path);
+      g_assert_not_reached ();
     }
 
   if (self->priv->socket_path)
-- 
1.5.6.5




More information about the telepathy-commits mailing list