~ubuntu-branches/ubuntu/gutsy/firefox/gutsy

« back to all changes in this revision

Viewing changes to security/manager/ssl/src/nsNSSCallbacks.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ian Jackson
  • Date: 2006-10-10 18:49:32 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20061010184932-da75izt7y0e59afq
Tags: 1.99+2.0rc2+dfsg-0ubuntu1
* New upstream version 2.0rc2.
* Fix/workaround for epiphany GtkSocket lifetype crash:
  apply patch id=241087 from Mozilla Bugzilla #241535 to fix LP #63814.
* Change application name to `Firefox', as requested by mdz.
  Files changed:
    - browser/locales/en-US/chrome/branding/brand.dtd
    - browser/locales/en-US/chrome/branding/brand.properties;
  New values:
    - brandShortName and brandFullName: `Bon Echo' => `Firefox'
    - vendorShortName: `Mozilla' => `Ubuntu'
* Make preferences dialogue fit again (bah!).

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
71
71
 
 
72
#ifdef PR_LOGGING
 
73
extern PRLogModuleInfo* gPIPNSSLog;
 
74
#endif
 
75
 
72
76
struct nsHTTPDownloadEvent : PLEvent {
73
77
  nsHTTPDownloadEvent();
74
78
  ~nsHTTPDownloadEvent();
264
268
                                                        const char **http_response_data, 
265
269
                                                        PRUint32 *http_response_data_len)
266
270
{
 
271
  PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
 
272
         ("nsNSSHttpRequestSession::trySendAndReceiveFcn to %s\n", mURL.get()));
 
273
 
267
274
  if (nsIThread::IsMainThread())
268
275
  {
269
276
    nsresult rv;
290
297
    return SECFailure;
291
298
  }
292
299
 
 
300
  const int max_retries = 5;
 
301
  int retry_count = 0;
 
302
  PRBool retryable_error = PR_FALSE;
 
303
  SECStatus result_sec_status = SECFailure;
 
304
 
 
305
  do
 
306
  {
 
307
    if (retry_count > 0)
 
308
    {
 
309
      if (retryable_error)
 
310
      {
 
311
        PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
 
312
               ("nsNSSHttpRequestSession::trySendAndReceiveFcn - sleeping and retrying: %d of %d\n",
 
313
                retry_count, max_retries));
 
314
      }
 
315
 
 
316
      PR_Sleep( PR_MillisecondsToInterval(300) * retry_count );
 
317
    }
 
318
 
 
319
    ++retry_count;
 
320
    retryable_error = PR_FALSE;
 
321
 
 
322
    result_sec_status =
 
323
      internal_send_receive_attempt(retryable_error, pPollDesc, http_response_code,
 
324
                                    http_response_content_type, http_response_headers,
 
325
                                    http_response_data, http_response_data_len);
 
326
  }
 
327
  while (retryable_error &&
 
328
         retry_count < max_retries);
 
329
 
 
330
#ifdef PR_LOGGING
 
331
  if (retry_count > 1)
 
332
  {
 
333
    if (retryable_error)
 
334
      PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
 
335
             ("nsNSSHttpRequestSession::trySendAndReceiveFcn - still failing, giving up...\n"));
 
336
    else
 
337
      PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
 
338
             ("nsNSSHttpRequestSession::trySendAndReceiveFcn - success at attempt %d\n",
 
339
              retry_count));
 
340
  }
 
341
#endif
 
342
 
 
343
  return result_sec_status;
 
344
}
 
345
 
 
346
SECStatus
 
347
nsNSSHttpRequestSession::internal_send_receive_attempt(PRBool &retryable_error,
 
348
                                                       PRPollDesc **pPollDesc,
 
349
                                                       PRUint16 *http_response_code,
 
350
                                                       const char **http_response_content_type,
 
351
                                                       const char **http_response_headers,
 
352
                                                       const char **http_response_data,
 
353
                                                       PRUint32 *http_response_data_len)
 
354
{
293
355
  if (pPollDesc) *pPollDesc = nsnull;
294
356
  if (http_response_code) *http_response_code = 0;
295
357
  if (http_response_content_type) *http_response_content_type = 0;
385
447
    return SECFailure;
386
448
 
387
449
  if (NS_FAILED(mListener->mResultCode))
 
450
  {
 
451
    if (mListener->mResultCode == NS_ERROR_CONNECTION_REFUSED
 
452
        ||
 
453
        mListener->mResultCode == NS_ERROR_NET_RESET)
 
454
    {
 
455
      retryable_error = PR_TRUE;
 
456
    }
388
457
    return SECFailure;
 
458
  }
389
459
 
390
460
  if (http_response_code)
391
461
    *http_response_code = mListener->mHttpResponseCode;
523
593
 
524
594
  nsresult rv = aLoader->GetRequest(getter_AddRefs(req));
525
595
  
 
596
#ifdef PR_LOGGING
 
597
  if (NS_FAILED(aStatus))
 
598
  {
 
599
    PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
 
600
           ("nsHTTPListener::OnStreamComplete status failed %d", aStatus));
 
601
  }
 
602
#endif
 
603
 
526
604
  if (NS_SUCCEEDED(rv))
527
605
    hchan = do_QueryInterface(req, &rv);
528
606