Mercurial > pidgin.yaz
comparison src/gtkconn.c @ 13991:87797e287549
[gaim-migrate @ 16565]
Randomize initial reconnect delay as not to DoS servers
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 24 Jul 2006 23:57:11 +0000 |
parents | 69e02f13b525 |
children |
comparison
equal
deleted
inserted
replaced
13990:ff4ee4ac4408 | 13991:87797e287549 |
---|---|
35 #include "gtkstatusbox.h" | 35 #include "gtkstatusbox.h" |
36 #include "gtkstock.h" | 36 #include "gtkstock.h" |
37 #include "gtkutils.h" | 37 #include "gtkutils.h" |
38 #include "util.h" | 38 #include "util.h" |
39 | 39 |
40 #define INITIAL_RECON_DELAY 8000 | 40 #define INITIAL_RECON_DELAY_MIN 8000 |
41 #define INITIAL_RECON_DELAY_MAX 60000 | |
42 | |
41 #define MAX_RECON_DELAY 600000 | 43 #define MAX_RECON_DELAY 600000 |
42 | 44 |
43 typedef struct { | 45 typedef struct { |
44 int delay; | 46 int delay; |
45 guint timeout; | 47 guint timeout; |
153 gaim_gtk_blist_update_account_error_state(account, text); | 155 gaim_gtk_blist_update_account_error_state(account, text); |
154 if (!gc->wants_to_die) { | 156 if (!gc->wants_to_die) { |
155 if (info == NULL) { | 157 if (info == NULL) { |
156 info = g_new0(GaimAutoRecon, 1); | 158 info = g_new0(GaimAutoRecon, 1); |
157 g_hash_table_insert(hash, account, info); | 159 g_hash_table_insert(hash, account, info); |
158 info->delay = INITIAL_RECON_DELAY; | 160 info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); |
159 } else { | 161 } else { |
160 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); | 162 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); |
161 if (info->timeout != 0) | 163 if (info->timeout != 0) |
162 g_source_remove(info->timeout); | 164 g_source_remove(info->timeout); |
163 } | 165 } |