substack/seaport — pull request #11 by mbrevoort (2012-07-17 04:02:18+00:00)
Title: added _id correlation avoiding roles criss cross on race condition

This is a fix for issue #10
https://github.com/substack/seaport/issues/10

The role lookup was only considering host and port so if an assume happened on reconnection before the connection end, the free from the original connection would free the reconnection's assume. I added an ID to the role object so that it would only free roles corresponding to the original allocation on that connection.

Incidentally, I can't get the tests to pass on my machine since commit 3226531edee015ef12e146887e6ce8be2d2f8746 though I see that it's testing fine on Travis. I can't spin my wheels anymore on this tonight but this change definitely fixes my issue. The tests fail on `resubscribe.js` and `resubscribe_delay.js` with this output.

./node_modules/.bin/tap --tap test/resubscribe.js
# TAP version 13
# resubscribe if connection dies
ok 1 allocate emitted
ok 2 assume emitted
ok 3 free emitted
ok 4 allocate emitted
ok 5 assume emitted
ok 6 free emitted
ok 7 allocate emitted
ok 8 assume emitted
ok 9 free emitted
not ok 10 test count != plan
---
file: node.js
line: 192
column: 40
stack:
- getCaller (/Users/mikebre/development/personal/seaport/node_modules/tap/lib/tap-assert.js:415:17)
- assert (/Users/mikebre/development/personal/seaport/node_modules/tap/lib/tap-assert.js:20:16)
- Function.equal (/Users/mikebre/development/personal/seaport/node_modules/tap/lib/tap-assert.js:161:10)
- Test.end (/Users/mikebre/development/personal/seaport/node_modules/tap/lib/tap-harness.js:116:31)
- Test._endNice (/Users/mikebre/development/personal/seaport/node_modules/tap/lib/tap-test.js:69:26)
- Array.0 (native)
- EventEmitter._tickCallback (node.js:192:40)
found: 9
wanted: 6
...
ok 11 closed server
# tests 11
# pass 10
# fail 1
not ok 12 test/resubscribe.js
---
timedOut: true
exit: 1
command: "node" "resubscribe.js"
...

1..12
# tests 12
# pass 10
# fail 2