From 1014b8008de81e8804a48dc8e961daf56cf9d6ab Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 15 Jul 2018 00:20:13 +0100 Subject: [PATCH] [pollock] fix a sequential download issue * Apparently you need to close the request/response as the Garbage Collection will not do that for you. High level language my ass! --- res/localization/Pollock.cs | 14 ++++++++------ src/rufus.rc | 10 +++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/res/localization/Pollock.cs b/res/localization/Pollock.cs index 0a3b03fa..3f6f0985 100644 --- a/res/localization/Pollock.cs +++ b/res/localization/Pollock.cs @@ -114,7 +114,6 @@ namespace pollock private static Encoding encoding = new UTF8Encoding(false); private static List rtl_languages = new List { "ar-SA", "he-IL", "fa-IR" }; private static Stopwatch sw = new System.Diagnostics.Stopwatch(); - private static WebClient wc = new WebClient(); private static DateTime last_changed = DateTime.MinValue; private static int download_status; private static int console_x_pos; @@ -726,12 +725,15 @@ namespace pollock { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); status = response.StatusCode; + response.Close(); } catch (WebException we) { HttpWebResponse response = we.Response as HttpWebResponse; status = response.StatusCode; + response.Close(); } + request.Abort(); switch (status) { case HttpStatusCode.OK: @@ -754,7 +756,7 @@ namespace pollock if (!ValidateDownload(url)) return null; - using (wc) + using (WebClient wc = new WebClient()) { try { @@ -789,7 +791,7 @@ namespace pollock return false; console_x_pos = Console.CursorLeft; - using (wc) + using (WebClient wc = new WebClient()) { wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted); @@ -823,13 +825,13 @@ namespace pollock { if (cancel_requested) { - wc.CancelAsync(); + ((WebClient)sender).CancelAsync(); return; } - if (in_progress) - return; // Prevent this call from being re-entrant + if (in_progress) + return; in_progress = true; speed = (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds); diff --git a/src/rufus.rc b/src/rufus.rc index c890809c..2050dda5 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.2.1336" +CAPTION "Rufus 3.2.1337" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,2,1336,0 - PRODUCTVERSION 3,2,1336,0 + FILEVERSION 3,2,1337,0 + PRODUCTVERSION 3,2,1337,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.2.1336" + VALUE "FileVersion", "3.2.1337" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.2.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.2.1336" + VALUE "ProductVersion", "3.2.1337" END END BLOCK "VarFileInfo"