fixing bug 86959 - win32 installer needs to log additional data

bug 87456 - download time out should automatically reconnect
r=sgehani
rs=mscott
This commit is contained in:
ssu%netscape.com 2001-06-29 21:52:58 +00:00
parent ffc5ee3c70
commit 1df8dc610d
8 changed files with 233 additions and 78 deletions

View File

@ -65,8 +65,8 @@
#endif
const int kUsecsPerSec = 1000000;
const int kTimeoutThresholdSecs = 120;
const int kTimeoutThresholdUsecs = kTimeoutThresholdSecs * kUsecsPerSec;
const int kRecvTimeoutThresholdUsecs = 30 * kUsecsPerSec;
const int kTimeoutThresholdUsecs = 120 * kUsecsPerSec;
const int kTimeoutSelectUsecs = 100000;
const int kKilobyte = 1024;
const int kUsecsPerKBFactor = (kUsecsPerSec/kKilobyte);
@ -312,7 +312,7 @@ nsSocket::Send(unsigned char *aBuf, int *aBufSize)
int
nsSocket::Recv(unsigned char *aBuf, int *aBufSize)
{
return(Recv(aBuf, aBufSize, kTimeoutThresholdUsecs));
return(Recv(aBuf, aBufSize, kRecvTimeoutThresholdUsecs));
}
int

View File

@ -2708,6 +2708,13 @@ void DlgSequenceNext()
/* PRE_DOWNLOAD process file manipulation functions */
ProcessFileOps(T_PRE_DOWNLOAD, NULL);
/* log if the user selected the turbo mode or not */
if(diStartInstall.bTurboModeEnabled)
{
LogISTurboMode(diStartInstall.bTurboMode);
LogMSTurboMode(diStartInstall.bTurboMode);
}
if(RetrieveArchives() == WIZ_OK)
{
/* POST_DOWNLOAD process file manipulation functions */

View File

@ -1403,7 +1403,6 @@ long RetrieveRedirectFile()
diAdvancedSettings.szProxyUser, /* proxy server user (optional) */
diAdvancedSettings.szProxyPasswd, /* proxy password (optional) */
FALSE, /* show retry message */
NULL, /* receive the number of network retries */
TRUE, /* ignore network error */
NULL, /* buffer to store the name of failed file */
0); /* size of failed file name buffer */
@ -1525,7 +1524,6 @@ long RetrieveArchives()
char szBuf[MAX_BUF];
char szPartiallyDownloadedFilename[MAX_BUF];
int iCRCRetries;
int iNetRetries;
int iRv;
/* retrieve the redirect.ini file */
@ -1579,7 +1577,6 @@ long RetrieveArchives()
* the archives is not considered a "retry". Subsequent downloads are
* considered retries. */
iCRCRetries = 0;
iNetRetries = 0;
bDone = FALSE;
do
{
@ -1595,7 +1592,6 @@ long RetrieveArchives()
diAdvancedSettings.szProxyUser, /* proxy server user (optional) */
diAdvancedSettings.szProxyPasswd, /* proxy password (optional) */
iCRCRetries, /* show retry message */
&iNetRetries, /* receive the number of network retries */
FALSE, /* ignore network error */
szFailedFile, /* buffer to store the name of failed file */
sizeof(szFailedFile)); /* size of failed file name buffer */
@ -1620,11 +1616,6 @@ long RetrieveArchives()
}
else
{
int iComponentIndex = SiCNodeGetIndexDS(szFailedFile);
siC *siCObject = SiCNodeGetObject(iComponentIndex, TRUE, AC_ALL);
++siCObject->iNetRetries;
/* Download failed. Error message was already shown by DownloadFiles().
* Simple exit loop here */
bDone = TRUE;
@ -1661,13 +1652,12 @@ long RetrieveArchives()
LogISComponentsFailedCRC(NULL, W_DOWNLOAD);
}
LogISDownloadProtocol(diDownloadOptions.dwUseProtocol);
LogMSDownloadProtocol(diDownloadOptions.dwUseProtocol);
if(lResult == WIZ_OK)
{
if(bDownloadTriggered)
LogISDownloadStatus("ok", NULL);
UnsetSetupCurrentDownloadFile();
UnsetDownloadState();
LogISDownloadStatus("ok", NULL);
}
else if(bDownloadTriggered)
{
@ -1675,7 +1665,15 @@ long RetrieveArchives()
LogISDownloadStatus(szBuf, szFailedFile);
}
/* We want to log the download status regardless if we downloaded or not. */
LogMSDownloadStatus(lResult);
if(lResult == WIZ_OK)
{
UnsetSetupCurrentDownloadFile();
UnsetDownloadState();
}
return(lResult);
}
@ -2574,6 +2572,7 @@ siC *CreateSiCNode()
siCNode->iNetRetries = 0;
siCNode->iCRCRetries = 0;
siCNode->iNetTimeOuts = 0;
siCNode->siCDDependencies = NULL;
siCNode->siCDDependees = NULL;
siCNode->Next = NULL;
@ -4876,7 +4875,7 @@ HRESULT CheckInstances()
else
szWN = szWindowName;
if((hwndFW = FindWindow(szClassName, szWN)) != NULL)
if((hwndFW = FindWindow(szCN, szWN)) != NULL)
{
if(*szMessage != '\0')
{

View File

@ -252,20 +252,60 @@ void LogISComponentsToDownload(void)
}
}
void LogISDownloadProtocol(DWORD dwProtocolType)
{
char szBuf[MAX_BUF];
char szProtocolType[MAX_BUF];
switch(dwProtocolType)
{
case UP_HTTP:
lstrcpy(szProtocolType, "HTTP");
break;
default:
lstrcpy(szProtocolType, "FTP");
break;
}
wsprintf(szBuf, "\n Download protocol: %s\n", szProtocolType);
UpdateInstallStatusLog(szBuf);
}
void LogISDownloadStatus(char *szStatus, char *szFailedFile)
{
char szBuf[MAX_BUF];
siC *siCObject = NULL;
DWORD dwIndex;
if(szFailedFile)
wsprintf(szBuf,
"\n Download status:\n %s\n file: %s\n",
"\n Download status: %s\n file: %s\n\n",
szStatus,
szFailedFile);
else
wsprintf(szBuf,
"\n Download status:\n %s\n",
"\n Download status: %s\n",
szStatus);
UpdateInstallStatusLog(szBuf);
dwIndex = 0;
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
while(siCObject)
{
if(siCObject->dwAttributes & SIC_SELECTED)
{
wsprintf(szBuf, " %s: NetRetries:%d, CRCRetries:%d, NetTimeOuts:%d\n",
siCObject->szDescriptionShort,
siCObject->iNetRetries,
siCObject->iCRCRetries,
siCObject->iNetTimeOuts);
UpdateInstallStatusLog(szBuf);
}
++dwIndex;
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
}
}
void LogISComponentsFailedCRC(char *szList, int iWhen)
@ -391,6 +431,18 @@ void LogISDiskSpace(dsN *dsnComponentDSRequirement)
}
}
void LogISTurboMode(BOOL bTurboMode)
{
char szBuf[MAX_BUF];
if(bTurboMode)
wsprintf(szBuf, "\n Turbo Mode: true\n");
else
wsprintf(szBuf, "\n Turbo Mode: false\n");
UpdateInstallStatusLog(szBuf);
}
void LogMSProductInfo(void)
{
char szBuf[MAX_BUF];
@ -418,6 +470,26 @@ void LogMSProductInfo(void)
AppendToGlobalMessageStream(szBuf);
}
void LogMSDownloadProtocol(DWORD dwProtocolType)
{
char szMessageStream[MAX_BUF_TINY];
char szProtocolType[MAX_BUF];
switch(dwProtocolType)
{
case UP_HTTP:
lstrcpy(szProtocolType, "HTTP");
break;
default:
lstrcpy(szProtocolType, "FTP");
break;
}
wsprintf(szMessageStream, "&DownloadProtocol=%s", szProtocolType);
AppendToGlobalMessageStream(szMessageStream);
}
void LogMSDownloadStatus(int iDownloadStatus)
{
char szMessageStream[MAX_BUF_TINY];
@ -438,15 +510,18 @@ void LogMSDownloadFileStatus(void)
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
while(siCObject)
{
if(siCObject->iNetRetries || siCObject->iCRCRetries)
if(siCObject->iNetRetries ||
siCObject->iCRCRetries ||
siCObject->iNetTimeOuts)
{
char szFileInfo[MAX_BUF_SMALL];
wsprintf(szFileInfo,
"&%s=%d,%d",
"&%s=%d,%d,%d",
siCObject->szArchiveName,
siCObject->iNetRetries,
siCObject->iCRCRetries);
siCObject->iCRCRetries,
siCObject->iNetTimeOuts);
lstrcat(szMessageStream, szFileInfo);
}
@ -481,3 +556,11 @@ void LogMSXPInstallStatus(char *szFile, int iErr)
gErrorMessageStream.bSendMessage = TRUE;
}
void LogMSTurboMode(BOOL bTurboMode)
{
char szMessageStream[MAX_BUF];
wsprintf(szMessageStream, "&TM=%d", bTurboMode);
AppendToGlobalMessageStream(szMessageStream);
}

View File

@ -32,6 +32,7 @@ void LogISComponentsSelected(void);
void LogISComponentsToDownload(void);
void LogISComponentsFailedCRC(char *szList, int iWhen);
void LogISDownloadStatus(char *szStatus, char *szFailedFile);
void LogISDownloadProtocol(DWORD dwProtocolType);
void LogISXPInstall(int iWhen);
void LogISXPInstallComponent(char *szComponentName);
void LogISXPInstallComponentResult(DWORD dwErrorNumber);
@ -39,10 +40,13 @@ void LogISLaunchApps(int iWhen);
void LogISLaunchAppsComponent(char *szComponentName);
void LogISProcessXpcomFile(int iStatus, int iResult);
void LogISDiskSpace(dsN *dsnComponentDSRequirement);
void LogISTurboMode(BOOL bTurboMode);
void LogMSProductInfo(void);
void LogMSDownloadFileStatus(void);
void LogMSDownloadStatus(int iDownloadStatus);
void LogMSDownloadProtocol(DWORD dwProtocolType);
void LogMSXPInstallStatus(char *szFile, int iErr);
void LogMSTurboMode(BOOL bTurboMode);
#endif /* _LOGGING_H_ */

View File

@ -421,6 +421,7 @@ struct sinfoComponent
BOOL bForceUpgrade;
int iNetRetries;
int iCRCRetries;
int iNetTimeOuts;
siCD *siCDDependencies;
siCD *siCDDependees;
siC *Next;

View File

@ -56,6 +56,7 @@ const int kProxySrvrLen = 1024;
const char kHTTP[8] = "http://";
const char kFTP[7] = "ftp://";
const char kLoclFile[7] = "zzzFTP";
const int kModTimeOutValue = 3;
static nsHTTPConn *connHTTP = NULL;
static nsFTPConn *connFTP = NULL;
@ -78,6 +79,8 @@ BOOL gbShowDownloadRetryMsg;
DWORD gdwDownloadDialogStatus;
int giIndex;
int giTotalArchivesToDownload;
DWORD gdwTickStart;
BOOL gbStartTickCounter;
double GetPercentSoFar(void);
@ -86,6 +89,9 @@ static void UpdateGaugeFileProgressBar(double value);
void InitDownloadDlg(void);
void DeInitDownloadDlg();
/* local prototypes */
siC *GetObjectFromArchiveName(char *szArchiveName);
struct DownloadFileInfo
{
char szUrl[MAX_BUF];
@ -108,9 +114,7 @@ struct TickInfo
DWORD dwTickDif;
BOOL bTickStarted;
BOOL bTickDownloadResumed;
};
struct TickInfo gtiPaused;
} gtiPaused;
BOOL CheckInterval(long *lModLastValue, int iInterval)
{
@ -218,7 +222,6 @@ void SetStatusStatus(void)
static long lModLastValue = 0;
double dRate;
static double dRateCounter;
static DWORD dwTickStart = 0;
DWORD dwTickNow;
DWORD dwTickDif;
DWORD dwKBytesSoFar;
@ -226,12 +229,12 @@ void SetStatusStatus(void)
char szTimeLeft[MAX_BUF_TINY];
/* If the user just clicked on the Resume button, then the time lapsed
* between dwTickStart and when the Resume button was clicked needs to
* between gdwTickStart and when the Resume button was clicked needs to
* be subtracted taken into account when calculating dwTickDif. So
* "this" lapsed time needs to be added to dwTickStart. */
* "this" lapsed time needs to be added to gdwTickStart. */
if(gtiPaused.bTickDownloadResumed)
{
dwTickStart = AddToTick(dwTickStart, gtiPaused.dwTickDif);
gdwTickStart = AddToTick(gdwTickStart, gtiPaused.dwTickDif);
InitTickInfo();
}
@ -239,10 +242,10 @@ void SetStatusStatus(void)
* which will allow us to get at a 2 decimal precision value for the
* download rate. */
dwTickNow = GetTickCount();
if(dwTickStart == 0)
dwTickNow = dwTickStart = GetTickCount();
if((gdwTickStart == 0) && gbStartTickCounter)
dwTickNow = gdwTickStart = GetTickCount();
dwTickDif = GetTickDif(dwTickNow, dwTickStart);
dwTickDif = GetTickDif(dwTickNow, gdwTickStart);
/* Only update the UI every UPDATE_INTERVAL_STATUS interval,
* which is currently set to 1 sec. */
@ -559,6 +562,7 @@ int DownloadViaProxyOpen(char *szUrl, char *szProxyServer, char *szProxyPort, ch
void DownloadViaProxyClose(void)
{
gbStartTickCounter = FALSE;
if(connHTTP)
{
connHTTP->Close();
@ -604,6 +608,7 @@ int DownloadViaProxy(char *szUrl, char *szProxyServer, char *szProxyPort, char *
if(strrchr(szUrl, '/') != (szUrl + strlen(szUrl)))
file = strrchr(szUrl, '/') + 1; // set to leaf name
gbStartTickCounter = TRUE;
rv = connHTTP->Get(ProgressCB, file); // use leaf from URL
DownloadViaProxyClose();
return(rv);
@ -634,6 +639,7 @@ int DownloadViaHTTPOpen(char *szUrl)
void DownloadViaHTTPClose(void)
{
gbStartTickCounter = FALSE;
if(connHTTP)
{
connHTTP->Close();
@ -674,6 +680,7 @@ int DownloadViaHTTP(char *szUrl)
if(strrchr(szUrl, '/') != (szUrl + strlen(szUrl)))
file = strrchr(szUrl, '/') + 1; // set to leaf name
gbStartTickCounter = TRUE;
rv = connHTTP->Get(ProgressCB, file);
DownloadViaHTTPClose();
return(rv);
@ -712,6 +719,7 @@ int DownloadViaFTPOpen(char *szUrl)
void DownloadViaFTPClose(void)
{
gbStartTickCounter = FALSE;
if(connFTP)
{
connFTP->Close();
@ -754,6 +762,7 @@ int DownloadViaFTP(char *szUrl)
if(strrchr(path, '/') != (path + strlen(path)))
file = strrchr(path, '/') + 1; // set to leaf name
gbStartTickCounter = TRUE;
rv = connFTP->Get(path, file, nsFTPConn::BINARY, TRUE, ProgressCB);
if(host)
@ -781,12 +790,6 @@ void PauseTheDownload(int rv, int *iFileDownloadRetries)
void CloseSocket(char *szProxyServer, char *szProxyPort)
{
DWORD dwSavedState = gdwDownloadDialogStatus;
// /* gdwDownloadDialogStatus needs to be not set before calling
// * CloseSocket(), or else the socket will not be properly closed */
// gdwDownloadDialogStatus = CS_NONE;
/* Close the socket connection from the first attempt. */
if((szProxyServer != NULL) && (szProxyPort != NULL) &&
(*szProxyServer != '\0') && (*szProxyPort != '\0'))
@ -800,7 +803,29 @@ void CloseSocket(char *szProxyServer, char *szProxyPort)
else if(strncmp(gszUrl, kFTP, lstrlen(kFTP)) == 0)
DownloadViaFTPClose();
}
// gdwDownloadDialogStatus = dwSavedState;
}
siC *GetObjectFromArchiveName(char *szArchiveName)
{
DWORD dwIndex;
siC *siCObject = NULL;
siC *siCNode = NULL;
dwIndex = 0;
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
while(siCObject)
{
if(lstrcmpi(szArchiveName, siCObject->szArchiveName) == 0)
{
siCNode = siCObject;
break;
}
++dwIndex;
siCObject = SiCNodeGetObject(dwIndex, TRUE, AC_ALL);
}
return(siCNode);
}
int DownloadFiles(char *szInputIniFile,
@ -810,7 +835,6 @@ int DownloadFiles(char *szInputIniFile,
char *szProxyUser,
char *szProxyPasswd,
BOOL bShowRetryMsg,
int *iNetRetries,
BOOL bIgnoreAllNetworkErrors,
char *szFailedFile,
DWORD dwFailedFileSize)
@ -824,11 +848,13 @@ int DownloadFiles(char *szInputIniFile,
int rv;
int iFileDownloadRetries;
int iIgnoreFileNetworkError;
int iLocalTimeOutCounter;
DWORD dwTotalEstDownloadSize;
char szPartiallyDownloadedFilename[MAX_BUF];
BOOL bDownloadInitiated;
char szTempURL[MAX_BUF];
char szWorkingURLPathOnly[MAX_BUF];
siC *siCCurrentFileObj = NULL;
ZeroMemory(szTempURL, sizeof(szTempURL));
ZeroMemory(szWorkingURLPathOnly, sizeof(szWorkingURLPathOnly));
@ -848,6 +874,11 @@ int DownloadFiles(char *szInputIniFile,
glLastBytesSoFar = 0;
glAbsoluteBytesSoFar = 0;
glBytesResumedFrom = 0;
gdwTickStart = 0; /* Initialize the counter used to
* calculate download rate */
gbStartTickCounter = FALSE; /* used to determine when to start
* the tick counter used to calculate
* the download rate */
gbUrlChanged = TRUE;
gbDlgDownloadMinimized = FALSE;
gbDlgDownloadJustMinimized = FALSE;
@ -912,6 +943,9 @@ int DownloadFiles(char *szInputIniFile,
RemoveSlash(szWorkingURLPathOnly);
wsprintf(gszUrl, "%s/%s", szWorkingURLPathOnly, szCurrentFile);
/* retrieve the file's data structure */
siCCurrentFileObj = GetObjectFromArchiveName(szCurrentFile);
if((*szPartiallyDownloadedFilename != 0) &&
(lstrcmpi(szPartiallyDownloadedFilename, szCurrentFile) == 0))
{
@ -938,6 +972,7 @@ int DownloadFiles(char *szInputIniFile,
SetSetupCurrentDownloadFile(szCurrentFile);
iFileDownloadRetries = 0;
iLocalTimeOutCounter = 0;
do
{
ProcessWindowsMessages();
@ -967,16 +1002,18 @@ int DownloadFiles(char *szInputIniFile,
if(gdwDownloadDialogStatus == CS_PAUSE)
{
CloseSocket(szProxyServer, szProxyPort);
PauseTheDownload(rv, &iFileDownloadRetries);
bDownloadInitiated = FALSE; // restart the download using new socket connection
/* rv needs to be set to something
* other than E_USER_CANCEL or E_OK */
rv = nsFTPConn::E_CMD_UNEXPECTED;
PauseTheDownload(rv, &iFileDownloadRetries);
bDownloadInitiated = FALSE; /* restart the download using
* new socket connection */
}
else
{
/* break out of the do loop */
/* user canceled; break out of the do loop */
break;
}
}
@ -984,42 +1021,71 @@ int DownloadFiles(char *szInputIniFile,
(rv != nsFTPConn::E_CMD_FAIL) &&
(gdwDownloadDialogStatus != CS_CANCEL))
{
/* We timed out. No response from the server, or
* we somehow lost connection. */
char szTitle[MAX_BUF_SMALL];
char szMsgDownloadPaused[MAX_BUF];
/* Start the pause tick counter here because we don't know how
* long before the user will dismiss the MessageBox() */
if(!gtiPaused.bTickStarted)
/* Incrememt the time out counter on E_TIMEOUT */
if(rv == nsSocket::E_TIMEOUT)
{
gtiPaused.dwTickBegin = GetTickCount();
gtiPaused.bTickStarted = TRUE;
gtiPaused.bTickDownloadResumed = FALSE;
++siCCurrentFileObj->iNetTimeOuts;
++iLocalTimeOutCounter;
}
/* The connection exepectedly dropped for some reason, so inform
* the user that the download will be Paused, and then update the
* Download dialog to show the Paused state. */
GetPrivateProfileString("Messages",
"MB_WARNING_STR",
"",
szTitle,
sizeof(szTitle),
szFileIniInstall);
GetPrivateProfileString("Strings",
"Message Download Paused",
"",
szMsgDownloadPaused,
sizeof(szMsgDownloadPaused),
szFileIniConfig);
MessageBox(dlgInfo.hWndDlg,
szMsgDownloadPaused,
szTitle,
MB_ICONEXCLAMATION);
CloseSocket(szProxyServer, szProxyPort);
PauseTheDownload(rv, &iFileDownloadRetries);
/* If the number of timeouts is %3 == 0, then let's pause
* the download process. Otherwise, just close the
* connection and open a new one to see if the download
* can be restarted automatically. */
if((rv != nsSocket::E_TIMEOUT) ||
(rv == nsSocket::E_TIMEOUT) && ((iLocalTimeOutCounter % kModTimeOutValue) == 0))
{
/* Start the pause tick counter here because we don't know how
* long before the user will dismiss the MessageBox() */
if(!gtiPaused.bTickStarted)
{
gtiPaused.dwTickBegin = GetTickCount();
gtiPaused.bTickStarted = TRUE;
gtiPaused.bTickDownloadResumed = FALSE;
}
/* The connection unexepectedly dropped for some reason, so inform
* the user that the download will be Paused, and then update the
* Download dialog to show the Paused state. */
GetPrivateProfileString("Messages",
"MB_WARNING_STR",
"",
szTitle,
sizeof(szTitle),
szFileIniInstall);
GetPrivateProfileString("Strings",
"Message Download Paused",
"",
szMsgDownloadPaused,
sizeof(szMsgDownloadPaused),
szFileIniConfig);
MessageBox(dlgInfo.hWndDlg,
szMsgDownloadPaused,
szTitle,
MB_ICONEXCLAMATION);
/* Let's make sure we're in a paused state */
gdwDownloadDialogStatus = CS_PAUSE;
PauseTheDownload(rv, &iFileDownloadRetries);
}
else
/* Let's make sure we're _not_ in a paused state */
gdwDownloadDialogStatus = CS_NONE;
}
++iFileDownloadRetries;
/* We don't count time outs as normal failures. We're
* keeping track of time outs differently. */
if(rv != nsSocket::E_TIMEOUT)
++iFileDownloadRetries;
if((iFileDownloadRetries > MAX_FILE_DOWNLOAD_RETRIES) &&
(rv != nsFTPConn::E_USER_CANCEL) &&
(gdwDownloadDialogStatus != CS_CANCEL))
@ -1058,12 +1124,8 @@ int DownloadFiles(char *szInputIniFile,
(gdwDownloadDialogStatus != CS_CANCEL) &&
(iFileDownloadRetries <= MAX_FILE_DOWNLOAD_RETRIES));
if((iFileDownloadRetries > MAX_FILE_DOWNLOAD_RETRIES) && iNetRetries)
/* Keep track of how many retries for only the file that had
* too many retries.
* We don't care about retries unless it's reached the limit
* because each retry should not count as a new download. */
*iNetRetries = iFileDownloadRetries - 1;
/* Save the number of retries for each file */
siCCurrentFileObj->iNetRetries = iFileDownloadRetries < 1 ? 0:iFileDownloadRetries - 1;
if((rv == nsFTPConn::E_USER_CANCEL) ||
(gdwDownloadDialogStatus == CS_CANCEL))

View File

@ -36,7 +36,6 @@ int DownloadFiles(char *szInputIniFile,
char *szProxyUser,
char *szProxyPasswd,
BOOL bShowRetryMsg,
int *iNetRetries,
BOOL bIgnoreNetworkError,
char *szFailedFile,
DWORD dwFailedFileSize);