~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to src/forward.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mahyuddin Susanto
  • Date: 2011-02-15 18:46:13 UTC
  • mfrom: (21.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110215184613-1u3dh5sz4i055flk
Tags: 3.1.10-1ubuntu1
* Merge from debian unstable. (LP: #719283)  Remaining changes:
  - debian/patches/18-fix-ftbfs-binutils-gold.dpatch: Add library linker into
    LIBS instead to LDFLAGS to fixing FTBFS binutils-gold.
* Drop Ubuntu configuration for ufw which landed in Debian and sync it: 
  - debian/squid3.ufw.profile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
 
165
165
    serversFree(&servers);
166
166
 
 
167
    doneWithRetries();
 
168
 
167
169
    HTTPMSGUNLOCK(request);
168
170
 
169
171
    if (err)
414
416
    if (shutting_down)
415
417
        return false;
416
418
 
 
419
    if (!self) { // we have aborted before the server called us back
 
420
        debugs(17, 5, HERE << "not retrying because of earlier abort");
 
421
        // we will be destroyed when the server clears its Pointer to us
 
422
        return false;
 
423
    }
 
424
 
417
425
    if (entry->store_status != STORE_PENDING)
418
426
        return false;
419
427
 
497
505
void
498
506
FwdState::retryOrBail()
499
507
{
500
 
    if (!self) { // we have aborted before the server called us back
501
 
        debugs(17, 5, HERE << "not retrying because of earlier abort");
502
 
        // we will be destroyed when the server clears its Pointer to us
503
 
        return;
504
 
    }
505
 
 
506
508
    if (checkRetry()) {
507
509
        int originserver = (servers->_peer == NULL);
508
510
        debugs(17, 3, "fwdServerClosed: re-forwarding (" << n_tries << " tries, " << (squid_curtime - start_t) << " secs)");
539
541
        return;
540
542
    }
541
543
 
542
 
    if (!err && shutting_down) {
 
544
    // TODO: should we call completed() here and move doneWithRetries there?
 
545
    doneWithRetries();
 
546
 
 
547
    if (self != NULL && !err && shutting_down) {
543
548
        errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
544
549
    }
545
550
 
546
551
    self = NULL;        // refcounted
547
552
}
548
553
 
 
554
// If the Server quits before nibbling at the request body, the body sender
 
555
// will not know (so that we can retry). Call this if we will not retry. We
 
556
// will notify the sender so that it does not get stuck waiting for space.
 
557
void
 
558
FwdState::doneWithRetries()
 
559
{
 
560
    if (request && request->body_pipe != NULL)
 
561
        request->body_pipe->expectNoConsumption();
 
562
}
 
563
 
549
564
// called by the server that failed after calling unregister()
550
565
void
551
566
FwdState::handleUnregisteredServerEnd()
581
596
            debugs(81, 1, "fwdNegotiateSSL: Error negotiating SSL connection on FD " << fd <<
582
597
                   ": " << ERR_error_string(ERR_get_error(), NULL) << " (" << ssl_error <<
583
598
                   "/" << ret << "/" << errno << ")");
584
 
            ErrorState *anErr = errorCon(ERR_SECURE_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 
599
            ErrorState *const anErr = makeConnectingError(ERR_SECURE_CONNECT_FAIL);
585
600
#ifdef EPROTO
586
601
 
587
602
            anErr->xerrno = EPROTO;
701
716
 
702
717
        debugs(17, 4, "fwdConnectDone: Unknown host: " << request->GetHost());
703
718
 
704
 
        ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 
719
        ErrorState *const anErr = makeConnectingError(ERR_DNS_FAIL);
705
720
 
706
721
        anErr->dnsError = dns.error;
707
722
 
710
725
        comm_close(server_fd);
711
726
    } else if (status != COMM_OK) {
712
727
        assert(fs);
713
 
        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 
728
        ErrorState *const anErr = makeConnectingError(ERR_CONNECT_FAIL);
714
729
        anErr->xerrno = xerrno;
715
730
 
716
731
        fail(anErr);
870
885
 
871
886
    // if IPv6 is disabled try to force IPv4-only outgoing.
872
887
    if (!Ip::EnableIpv6 && !outgoing.SetIPv4()) {
873
 
        debugs(50, 4, "fwdConnectStart: " << xstrerror());
 
888
        debugs(50, 4, "fwdConnectStart: IPv6 is Disabled. Cannot connect from " << outgoing);
874
889
        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
875
 
        anErr->xerrno = errno;
 
890
        anErr->xerrno = EAFNOSUPPORT;
876
891
        fail(anErr);
877
892
        self = NULL;    // refcounted
878
893
        return;
1153
1168
    return reforwardableStatus(s);
1154
1169
}
1155
1170
 
 
1171
/**
 
1172
 * Create "503 Service Unavailable" or "504 Gateway Timeout" error depending
 
1173
 * on whether this is a validation request. RFC 2616 says that we MUST reply
 
1174
 * with "504 Gateway Timeout" if validation fails and cached reply has
 
1175
 * proxy-revalidate, must-revalidate or s-maxage Cache-Control directive.
 
1176
 */
 
1177
ErrorState *
 
1178
FwdState::makeConnectingError(const err_type type) const
 
1179
{
 
1180
    return errorCon(type, request->flags.need_validation ?
 
1181
                    HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
 
1182
}
 
1183
 
1156
1184
static void
1157
1185
fwdStats(StoreEntry * s)
1158
1186
{