haskell-distributed / distributed-process

Cloud Haskell core libraries
http://haskell-distributed.github.io
713 stars 97 forks source link

[NTTCP-12] Fix potential locking when waiting on the crossed MVar #441

Open qnikst opened 9 years ago

qnikst commented 9 years ago

[Imported from JIRA. Reported by Facundo Dominguez @facundominguez) as NTTCP-12 on 2015-05-27 20:55:45] The handler of incomming requests is waiting on the {{crossed}} MVar before accepting an incoming connection.

This wait is potentially indefinite (if the CrossConnectRequest message does not arrive), and it looks unnecessary. At least I cannot come up with any problematic interleaving of events in the absence of it.

We should either remove the {{crossed}} MVar or document what is helping to accomplish (preferrably the problematic ordering of events that is being ruled out).

There is the commit [message|https://github.com/haskell-distributed/network-transport-tcp/commit/6207de60bae7fcf39c108a49bdc152a98abdd277] of the commit that introduces it. Unfortunately, it doesn't explain the "certain ordering of events" that motivates it.

yihuang commented 6 years ago

It waits for the crossed MVar because it needs to wait for the crossing connecting process finish. I just put some thoughts into this crossing states today and find other potential problems, which I described in another issue.