Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Race condition for same ports #6
Today I started 5 apps at the same time (all doing the same with the same code) with
It all points to line 103 and further in net.js where, because of the process.nextTick, another 'process' (in my case another app) can bind first to the 'free' port. And the other app will fail with a
Luckily I remembered that @bmeck also made a pull request for node (see joyent/node#1412) and I noticed that that code is different then the current code for _doListen in net.js. Especially the code between the 2nd try..catch is different where in the pull code there is another check for
Implementing the pull code solved the problem so maybe can someone implement the new code in net.js ??
BTW the actual and desired in the
Nope it still crashes at:
I added a check for
See https://gist.github.com/1142394 for the total code I debugged together. I don't use your for loop!! Thats why I didn't want to make a pull of it... (the other reason for not making a pull is that I don't fully understand the why and what of the old code and I don't want to break things...)
added a commit
Aug 12, 2011
Your fix solved it almost only I got now:
Putting in a
In my pull request I also solved the event data (correct desired and port property data).
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Ok, I created a test program for this issue. The repo is here: email@example.com:stolsma/haibu-carapace-test.git
Running with node test.js will create most of the times the following error:
Sometimes also the following error is raised but I think thats related to the crash of the connected child:
Hope this is enough to crate the same errors at your computers...