~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/comm_select.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: comm_select.cc,v 1.81.4.1 2008/02/25 03:45:24 amosjeffries Exp $
 
3
 * $Id$
4
4
 *
5
5
 * DEBUG: section 5     Socket Functions
6
6
 *
20
20
 *  it under the terms of the GNU General Public License as published by
21
21
 *  the Free Software Foundation; either version 2 of the License, or
22
22
 *  (at your option) any later version.
23
 
 *  
 
23
 *
24
24
 *  This program is distributed in the hope that it will be useful,
25
25
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
26
26
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
27
 *  GNU General Public License for more details.
28
 
 *  
 
28
 *
29
29
 *  You should have received a copy of the GNU General Public License
30
30
 *  along with this program; if not, write to the Free Software
31
31
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
79
79
 * of incoming ICP, then we need to check these sockets more than
80
80
 * if we just have HTTP.
81
81
 *
82
 
 * The variables 'incoming_icp_interval' and 'incoming_http_interval' 
 
82
 * The variables 'incoming_icp_interval' and 'incoming_http_interval'
83
83
 * determine how many normal I/O events to process before checking
84
84
 * incoming sockets again.  Note we store the incoming_interval
85
85
 * multipled by a factor of (2^INCOMING_FACTOR) to have some
100
100
 *  incoming_interval = incoming_interval + target_average - number_of_events_processed
101
101
 *
102
102
 * There are separate incoming_interval counters for both HTTP and ICP events
103
 
 * 
 
103
 *
104
104
 * You can see the current values of the incoming_interval's, as well as
105
105
 * a histogram of 'incoming_events' by asking the cache manager
106
106
 * for 'comm_incoming', e.g.:
433
433
        if (msec > MAX_POLL_TIME)
434
434
            msec = MAX_POLL_TIME;
435
435
 
436
 
        if (comm_iocallbackpending())
437
 
            pending++;
438
 
 
439
436
        if (pending)
440
437
            msec = 0;
441
438
 
444
441
            poll_time.tv_usec = (msec % 1000) * 1000;
445
442
            statCounter.syscalls.selects++;
446
443
            num = select(maxfd, &readfds, &writefds, NULL, &poll_time);
447
 
            statCounter.select_loops++;
 
444
            ++statCounter.select_loops;
448
445
 
449
446
            if (num >= 0 || pending > 0)
450
447
                break;
526
523
                    (void) 0;
527
524
                else {
528
525
                    F->read_handler = NULL;
529
 
                    F->flags.read_pending = 0;
 
526
                    F->flags.read_pending = 0;
530
527
                    commUpdateReadBits(fd, NULL);
531
528
                    hdl(fd, F->read_data);
532
529
                    statCounter.select_fds++;
619
616
        statCounter.select_time += (current_dtime - start);
620
617
 
621
618
        return COMM_OK;
622
 
    } while (timeout > current_dtime)
623
 
 
624
 
        ;
 
619
    } while (timeout > current_dtime);
625
620
    debugs(5, 8, "comm_select: time out: " << squid_curtime);
626
621
 
627
622
    return COMM_TIMEOUT;
659
654
    statHistCount(&statCounter.comm_dns_incoming, nevents);
660
655
}
661
656
 
 
657
static void
 
658
commSelectRegisterWithCacheManager(void)
 
659
{
 
660
    CacheManager::GetInstance()->
 
661
    registerAction("comm_select_incoming",
 
662
                   "comm_incoming() stats",
 
663
                   commIncomingStats, 0, 1);
 
664
}
 
665
 
662
666
void
663
667
comm_select_init(void)
664
668
{
667
671
    FD_ZERO(&global_readfds);
668
672
    FD_ZERO(&global_writefds);
669
673
    nreadfds = nwritefds = 0;
670
 
}
671
674
 
672
 
void
673
 
commSelectRegisterWithCacheManager(CacheManager & manager)
674
 
{
675
 
    manager.registerAction("comm_select_incoming",
676
 
                           "comm_incoming() stats",
677
 
                           commIncomingStats, 0, 1);
 
675
    commSelectRegisterWithCacheManager();
678
676
}
679
677
 
680
678
/*
684
682
 * and the server side of a cache fetch simultaneoulsy abort the
685
683
 * connection.  While I haven't really studied the code to figure out how
686
684
 * it happens, the snippet below may prevent the cache from exitting:
687
 
 * 
 
685
 *
688
686
 * Call this from where the select loop fails.
689
687
 */
690
688
static int
695
693
    fd_set write_x;
696
694
 
697
695
    struct timeval tv;
698
 
    close_handler *ch = NULL;
 
696
    AsyncCall::Pointer ch = NULL;
699
697
    fde *F = NULL;
700
698
 
701
699
    struct stat sb;
714
712
            continue;
715
713
 
716
714
        statCounter.syscalls.selects++;
717
 
 
718
715
        errno = 0;
719
716
 
720
717
        if (!fstat(fd, &sb)) {
726
723
        debugs(5, 0, "FD " << fd << ": " << xstrerror());
727
724
        debugs(5, 0, "WARNING: FD " << fd << " has handlers, but it's invalid.");
728
725
        debugs(5, 0, "FD " << fd << " is a " << fdTypeStr[F->type] << " called '" << F->desc << "'");
729
 
        debugs(5, 0, "tmout:" << F->timeout_handler << " read:" << F->read_handler << " write:" << F->write_handler);
730
 
 
731
 
        for (ch = F->closeHandler; ch; ch = ch->next)
732
 
            debugs(5, 0, " close handler: " << ch->handler);
733
 
 
734
 
        if (F->closeHandler) {
 
726
        debugs(5, 0, "tmout:" << F->timeoutHandler << " read:" << F->read_handler << " write:" << F->write_handler);
 
727
 
 
728
        for (ch = F->closeHandler; ch != NULL; ch = ch->Next())
 
729
            debugs(5, 0, " close handler: " << ch);
 
730
 
 
731
        if (F->closeHandler != NULL) {
735
732
            commCallCloseHandlers(fd);
736
 
        } else if (F->timeout_handler) {
 
733
        } else if (F->timeoutHandler != NULL) {
737
734
            debugs(5, 0, "examine_select: Calling Timeout Handler");
738
 
            F->timeout_handler(fd, F->timeout_data);
 
735
            ScheduleCallHere(F->timeoutHandler);
739
736
        }
740
737
 
741
738
        F->closeHandler = NULL;
742
 
        F->timeout_handler = NULL;
 
739
        F->timeoutHandler = NULL;
743
740
        F->read_handler = NULL;
744
741
        F->write_handler = NULL;
745
742
        FD_CLR(fd, readfds);