Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/EionRobb/pidgin-opensteamworks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEion Robb <eion@robbmob.com>2019-01-17 12:15:06 +0300
committerEion Robb <eion@robbmob.com>2019-01-17 12:15:06 +0300
commitfeece3ce45e769660e36f9cd347f54003c95babf (patch)
tree6ee05668b93dbd3d14ac247fb1d8ebef300bc65b
parentb16a636d177f4a8862abdfbdb2c0994712ea0cd3 (diff)
Add a delay when re-requesting a url to not trigger rate-limiting
-rw-r--r--steam-mobile/steam_connection.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/steam-mobile/steam_connection.c b/steam-mobile/steam_connection.c
index 2f845c3..0bc3816 100644
--- a/steam-mobile/steam_connection.c
+++ b/steam-mobile/steam_connection.c
@@ -183,6 +183,17 @@ static void steam_update_cookies(SteamAccount *sa, const gchar *headers)
}
}
+static gboolean
+steam_connection_requeue_delay(gpointer data)
+{
+ SteamConnection *steamcon = data;
+
+ if (steamcon && steamcon->sa && steamcon->sa->waiting_conns)
+ g_queue_push_head(steamcon->sa->waiting_conns, steamcon);
+
+ return FALSE;
+}
+
static void steam_connection_process_data(SteamConnection *steamcon)
{
gssize len;
@@ -220,15 +231,16 @@ static void steam_connection_process_data(SteamConnection *steamcon)
if (strstr(steamcon->rx_buf, "429 Too Many Requests")) {
g_free(steamcon->rx_buf);
steamcon->rx_buf = NULL;
+ steamcon->rx_len = 0;
g_free(tmp);
//We got rate-limited, try again
SteamConnection *steamcon_dup = g_memdup(steamcon, sizeof(steamcon));
- steamcon_dup->request = steamcon->request; steamcon->request = NULL;
- steamcon_dup->url = steamcon->url; steamcon->url = NULL;
- steamcon_dup->hostname = steamcon->hostname; steamcon->hostname = NULL;
+ steamcon->request = NULL;
+ steamcon->url = NULL;
+ steamcon->hostname = NULL;
- g_queue_push_head(steamcon->sa->waiting_conns, steamcon_dup);
+ purple_timeout_add_seconds(1, steam_connection_requeue_delay, steamcon_dup);
return;
}
}