gnome-session/gnome-session-bnc385150-performance-hostname.patch

54 lines
1.6 KiB
Diff

--- pristine-gnome-session-2.22.1.1/gnome-session/manager.c 2008-04-10 15:32:20.000000000 +0100
+++ gnome-session-2.22.1.1/gnome-session/manager.c 2008-04-30 10:53:27.000000000 +0100
@@ -825,7 +825,6 @@
return retval;
}
-
static Status
register_client (SmsConn connection, SmPointer data, char *previous_id)
{
@@ -882,33 +881,20 @@
}
else
{
- char *id = SmsGenerateClientID (connection);
-
- if (id != NULL)
- {
- client->id = g_strdup (id);
- free (id);
- }
- else
+ /* If your network is mis-configured, it takes 15+ seconds for
+ SmsGenerateClientID to fail each time it is called - and since
+ the X method (libSM/src/sm_genid.c) does little of any value -
+ beyond creating a unique identifier - we do that ourselves
+ here instead rather more quickly. */
{
static long int sequence = 0;
- static char* address = NULL;
-
- if (! address)
- {
- g_warning ("Host name lookup failure on localhost.");
-
- address = g_new (char, 10);
- srand (time (NULL) + (getpid () <<16));
- g_snprintf (address, 10, "0%.8x", rand());
- };
/* The typecast there is for 64-bit machines */
- client->id = g_malloc (43);
- g_snprintf (client->id, 43, "1%s%.13ld%.10ld%.4ld", address,
- (long) time(NULL), (long) getpid (), sequence);
+ client->id = g_strdup_printf ("10%.8x%.13ld%.10ld%.4ld",
+ g_str_hash (g_get_host_name()),
+ (long) time(NULL), (long) getpid (),
+ sequence);
sequence++;
-
sequence %= 10000;
}
}