Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Making incoming connection <-> peer association world class #135

Open
Raynos opened this issue Oct 26, 2015 · 1 comment
Open

Making incoming connection <-> peer association world class #135

Raynos opened this issue Oct 26, 2015 · 1 comment
Labels

Comments

@Raynos
Copy link
Contributor

Raynos commented Oct 26, 2015

Currently the way we associate incoming connections with the correct peer on the root channel is by reaching into the channel when we finish the init handshake for incoming connections.

See https://github.com/uber/tchannel-node/blob/master/connection.js#L466-L482

TChannelConnection.prototype.onInIdentified = function onInIdentified(init) {
    var self = this;
    if (init.hostPort === '0.0.0.0:0') {
        self.ephemeral = true;
        self.remoteName = '' + self.socket.remoteAddress + ':' + self.socket.remotePort;
        assert(self.remoteName !== self.channel.hostPort,
              'should not be able to receive ephemeral connection from self');
    } else {
        self.remoteName = init.hostPort;
    }

    self.channel.peers.add(self.remoteName).addConnection(self);
    self.identifiedEvent.emit(self, {
        hostPort: self.remoteName,
        processName: init.processName
    });
};

Note that there is a horrible bug here where we completely ignore the peer.draining and peer.closing state and just blindly addConnection.

Either we should check the state here or make addConnection more world class.

@jcorbin
Copy link
Contributor

jcorbin commented Oct 26, 2015

I'd argue for the practical:

  • if draining, drain this new connection (if direction match in the peer draining case, chan draining is always)
  • if peer closing: no connection for you, close it

@jcorbin jcorbin added the bug label Oct 26, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants