Ignore:
Timestamp:
Nov 30, 2015, 11:50:54 PM (9 years ago)
Author:
Jason Gross <jgross@mit.edu>
Branches:
master, release-1.10
Children:
ba8ee40, ff58239
Parents:
d4f33f1
git-author:
Jason Gross <jgross@mit.edu> (07/13/15 14:51:30)
git-committer:
Jason Gross <jgross@mit.edu> (11/30/15 23:50:54)
Message:
Buffer IRC rejoins

This fixes [#274](https://barnowl.mit.edu/ticket/274), irc-rejoin code
is broken for > 20-26 channels.  We now send the rejoin requests in
groups of 15, every 5 seconds.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    rbe43554 r4379288  
    437437}
    438438
     439sub rejoin_channels {
     440    my $self = shift;
     441    my @channels = @_;
     442    # As reported in https://barnowl.mit.edu/ticket/274, if we reconnect to
     443    # too many at once, the server rejects us.  Empirically, this is about
     444    # 20-26, so we set the cap at 15, then delay further joins for 5 seconds.
     445    my $MAX_RECONNECT_CHANNELS = 15;
     446    my $DELAY = 5;
     447    foreach my $c (@channels[ 0 .. $MAX_RECONNECT_CHANNELS ]) {
     448        $self->conn->send_msg(join => $c);
     449    }
     450    if ($MAX_RECONNECT_CHANNELS < $#channels) {
     451        my $remaining = $#channels - $MAX_RECONNECT_CHANNELS;
     452        my $cur_alias = $self->alias;
     453        BarnOwl::admin_message('IRC', "[$cur_alias] Delaying $remaining autorejoins for $DELAY seconds");
     454        # if we don't assign the timer to anything, then it gets garbage
     455        # collected, and never runs
     456        $self->{autoconnect_channels_delay_timer} = BarnOwl::Timer->new({
     457            name  => "IRC rejoin overflow timer ($remaining remaining)",
     458            after => $DELAY,
     459            cb    => sub {
     460                rejoin_channels($self, @channels[ $MAX_RECONNECT_CHANNELS .. $#channels ]);
     461            }
     462        });
     463    }
     464}
     465
     466
    439467sub connected {
    440468    my $self = shift;
     
    443471    $self->cancel_reconnect;
    444472    if ($self->autoconnect_channels) {
    445         for my $c (@{$self->autoconnect_channels}) {
    446             $self->conn->send_msg(join => $c);
    447         }
     473        rejoin_channels($self, @{$self->autoconnect_channels});
    448474    }
    449475    $self->conn->enable_ping(60, sub {
Note: See TracChangeset for help on using the changeset viewer.