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:
authoreionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2013-07-03 05:15:41 +0400
committereionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2013-07-03 05:15:41 +0400
commitbaea6d0efc4fff9aee2599ad78ef7672feb771f7 (patch)
treea73e3116e382102ea0f02f4e585c6010491bdfb7
parent7c78662a3b3da096dee3325083994fd014a2f3bb (diff)
Retry http connections up to thrice on failure, so that the account isn't disabled on flakey connections
-rw-r--r--steam-mobile/steam_connection.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/steam-mobile/steam_connection.c b/steam-mobile/steam_connection.c
index 189c4f1..620221d 100644
--- a/steam-mobile/steam_connection.c
+++ b/steam-mobile/steam_connection.c
@@ -89,28 +89,43 @@ static gchar *steam_gunzip(const guchar *gzip_data, gssize *len_ptr)
return g_string_free(output_string, FALSE);
}
-void steam_connection_destroy(SteamConnection *steamcon)
+void
+steam_connection_close(SteamConnection *steamcon)
{
steamcon->sa->conns = g_slist_remove(steamcon->sa->conns, steamcon);
-
- if (steamcon->request != NULL)
- g_string_free(steamcon->request, TRUE);
-
- g_free(steamcon->rx_buf);
-
- if (steamcon->connect_data != NULL)
+
+ if (steamcon->connect_data != NULL) {
purple_proxy_connect_cancel(steamcon->connect_data);
+ steamcon->connect_data = NULL;
+ }
- if (steamcon->ssl_conn != NULL)
+ if (steamcon->ssl_conn != NULL) {
purple_ssl_close(steamcon->ssl_conn);
+ steamcon->ssl_conn = NULL;
+ }
if (steamcon->fd >= 0) {
close(steamcon->fd);
+ steamcon->fd = -1;
}
- if (steamcon->input_watcher > 0)
+ if (steamcon->input_watcher > 0) {
purple_input_remove(steamcon->input_watcher);
+ steamcon->input_watcher = 0;
+ }
+
+ g_free(steamcon->rx_buf);
+ steamcon->rx_buf = NULL;
+ steamcon->rx_len = 0;
+}
+void steam_connection_destroy(SteamConnection *steamcon)
+{
+ steam_connection_close(steamcon);
+
+ if (steamcon->request != NULL)
+ g_string_free(steamcon->request, TRUE);
+
g_free(steamcon->url);
g_free(steamcon->hostname);
g_free(steamcon);
@@ -272,8 +287,17 @@ static void steam_post_or_get_readdata_cb(gpointer data, gint source,
purple_debug_warning("steam",
"ssl error, but data received. attempting to continue\n");
} else {
- /* TODO: Is this a regular occurrence? If so then maybe resend the request? */
- steam_fatal_connection_cb(steamcon);
+ /* Try resend the request */
+ steamcon->retry_count++;
+ if (steamcon->retry_count < 3) {
+ steam_connection_close(steamcon);
+ steamcon->request_time = time(NULL);
+
+ g_queue_push_head(sa->waiting_conns, steamcon);
+ steam_next_connection(sa);
+ } else {
+ steam_fatal_connection_cb(steamcon);
+ }
return;
}
}