message: Per network reconnect limits
diff: @@ -9,8 +9,6 @@ const log = require("../logging").get("ClientPool");
  const Promise = require("bluebird");
  const QueuePool = require("../util/QueuePool");
  -const CONCURRENT_RECONNECT_LIMIT = 50;
  -
  function ClientPool(ircBridge) {
  this._ircBridge = ircBridge;
  // The list of bot clients on servers (not specific users)
  @@ -36,13 +34,10 @@ function ClientPool(ircBridge) {
  this._virtualClientCounts = {
  // server_domain: number
  };
  - this._reconnectQueue = new QueuePool(
  - CONCURRENT_RECONNECT_LIMIT,
  - (item) => {
  - log.info(`Reconnecting client. ${this._reconnectQueue.waitingItems} left.`);
  - return this._reconnectClient(item);
  - }
  - );
  +
  + this._reconnectQueues = {
  + // server_domain: QueuePool
  + };
  }
  ClientPool.prototype.killAllClients = function() {
  @@ -73,6 +68,23 @@ ClientPool.prototype.killAllClients = function() {
  );
  }
  +ClientPool.prototype.getOrCreateReconnQueue = function(server) {
  + if (server.getConcurrentReconnectLimit() === 0) {
  + return null;
  + }
  + let q = this._reconnectQueues[server.domain];
  + if (q === undefined) {
  + q = this._reconnectQueues[server.domain] = new QueuePool(
  + server.getConcurrentReconnectLimit(),
  + (item) => {
  + log.info(`Reconnecting client. ${this._reconnectQueue.waitingItems} left.`);
  + return this._reconnectClient(item);
  + }
  + );
  + }
  + return q;
  +};
  +
  ClientPool.prototype.setBot = function(server, client) {
  this._botClients[server.domain] = client;
  };
  @@ -288,8 +300,16 @@ ClientPool.prototype._onClientDisconnected = function(bridgedClient) {
  log.info(`Dropping ${cli._id} ${cli.nick} because they are not joined to any channels`);
  return;
  }
  + let queue = this.getOrCreateReconnQueue(bridgedClient.server);
  + if (queue === null) {
  + this._reconnectClient({
  + cli: cli,
  + chanList: chanList,
  + });
  + return;
  + }
  - this._reconnectQueue.enqueue(cli._id, {
  + queue.enqueue(cli._id, {
  cli: cli,
  chanList: chanList,
  });
  