comparison libpurple/protocols/jabber/bosh.c @ 26461:43cfca2eab64

A better random number for the rid in the range [0, 2**52).
author Paul Aurich <paul@darkrain42.org>
date Sat, 04 Apr 2009 21:49:34 +0000
parents 5172ebcc8673
children e0218e4ec785
comparison
equal deleted inserted replaced
26460:680b54e417c1 26461:43cfca2eab64
174 174
175 g_free(user); 175 g_free(user);
176 g_free(passwd); 176 g_free(passwd);
177 177
178 conn->js = js; 178 conn->js = js;
179 /* FIXME: This doesn't seem very random */ 179
180 conn->rid = rand() % 100000 + 1728679472; 180 /*
181 * Random 64-bit integer masked off by 2^52 - 1.
182 *
183 * This should produce a random integer in the range [0, 2^52). It's
184 * unlikely we'll send enough packets in one session to overflow the rid.
185 */
186 conn->rid = ((guint64)g_random_int() << 32) | g_random_int();
187 conn->rid &= 0xFFFFFFFFFFFFF;
181 188
182 conn->pending = purple_circ_buffer_new(0 /* default grow size */); 189 conn->pending = purple_circ_buffer_new(0 /* default grow size */);
183 190
184 conn->ready = FALSE; 191 conn->ready = FALSE;
185 if (purple_strcasestr(url, "https://") != NULL) 192 if (purple_strcasestr(url, "https://") != NULL)