Mgr: Shorten Internet timeout for notices on Windows to 5 seconds

This commit is contained in:
Charlie Fenton 2012-12-18 05:21:03 -08:00 committed by Oliver Bock
parent d90d77a9c0
commit 81a7299d35
2 changed files with 21 additions and 4 deletions

View File

@ -7753,3 +7753,9 @@ Charlie 18 Dec 2012
clientgui/ clientgui/
NoticeListCtrl.cpp,.h NoticeListCtrl.cpp,.h
ViewNotices.cpp,.h ViewNotices.cpp,.h
Charlie 18 Dec 2012
- Mgr: Shorten Internet timeout for notices on Windows to 5 seconds.
clientgui/
BOINCHtmlLBox.cpp

View File

@ -15,6 +15,9 @@
#include "BOINCInternetFSHandler.h" #include "BOINCInternetFSHandler.h"
#include "BOINCGUIApp.h" #include "BOINCGUIApp.h"
#include "MainDocument.h" #include "MainDocument.h"
#include "util.h"
#define STANDARD_INTERNET_DELAY 5
class MemFSHashObj : public wxObject class MemFSHashObj : public wxObject
{ {
@ -240,14 +243,18 @@ size_t wxWinINetInputStream::OnSysRead(void *buffer, size_t bufsize)
bufs.dwBufferLength = (DWORD)bufsize; bufs.dwBufferLength = (DWORD)bufsize;
lastInternetStatus = 0; lastInternetStatus = 0;
double endtimeout = dtime() + STANDARD_INTERNET_DELAY;
complete = InternetReadFileEx(m_hFile, &bufs, IRF_ASYNC | IRF_USE_CONTEXT, 2); complete = InternetReadFileEx(m_hFile, &bufs, IRF_ASYNC | IRF_USE_CONTEXT, 2);
if (!complete) { if (!complete) {
lError = ::GetLastError(); lError = ::GetLastError();
if ((lError == WSAEWOULDBLOCK) || (lError == ERROR_IO_PENDING)){ if ((lError == WSAEWOULDBLOCK) || (lError == ERROR_IO_PENDING)){
while (!operationEnded) { while (!operationEnded) {
if (b_ShuttingDown || (!pDoc->IsConnected())) { if (b_ShuttingDown ||
SetError(wxSTREAM_EOF); (!pDoc->IsConnected()) ||
(dtime() > endtimeout)
) {
SetError(wxSTREAM_EOF);
return 0; return 0;
} }
wxGetApp().Yield(true); wxGetApp().Yield(true);
@ -326,7 +333,7 @@ wxInputStream *wxWinINetURL::GetInputStream(wxURL *owner)
{ {
static bool bAlreadyRunning = false; static bool bAlreadyRunning = false;
if (bAlreadyRunning) { if (bAlreadyRunning) {
printf(stderr, "wxWinINetURL::GetInputStream reentered!"); fprintf(stderr, "wxWinINetURL::GetInputStream reentered!");
return NULL; return NULL;
} }
bAlreadyRunning = true; bAlreadyRunning = true;
@ -359,6 +366,7 @@ static bool bAlreadyRunning = false;
wxWinINetInputStream *newStream = new wxWinINetInputStream; wxWinINetInputStream *newStream = new wxWinINetInputStream;
operationEnded = false; operationEnded = false;
double endtimeout = dtime() + STANDARD_INTERNET_DELAY;
HINTERNET newStreamHandle = InternetOpenUrl HINTERNET newStreamHandle = InternetOpenUrl
( (
@ -372,7 +380,10 @@ static bool bAlreadyRunning = false;
); );
while (!operationEnded) { while (!operationEnded) {
if (b_ShuttingDown || (!pDoc->IsConnected())) { if (b_ShuttingDown ||
(!pDoc->IsConnected()) ||
(dtime() > endtimeout)
) {
GetSessionHandle(); // Closes the session GetSessionHandle(); // Closes the session
if (newStreamHandle) { if (newStreamHandle) {
delete newStreamHandle; delete newStreamHandle;