Fixing a bug with Messenger which allowed subscribers to add/remove subscribers during OnReceiveMessage that would themselves send a message, pushing through the add/remove before the original OnReceiveMessage call completed. This would cause a list mutation error since it happened within a foreach loop.
{Debug.LogError("OnReceiveMessage recursion detected! Is something calling OnReceiveMessage when it receives a message?");
return;
}
if(m_recurseCount==0)// This will increment if a new or existing subscriber calls OnReceiveMessage while handling a message. This is expected occasionally but shouldn't go too deep.
/// If a subscriber is added/removed during an OnReceiveMessage call and it immediately sends its own message, we must ensure that we don't process the change in the subscriber list.
/// (During a foreach loop, this is the "Collection was modified" error.)
/// </summary>
[Test]
[Timeout(100)]// These recursion tests could recurse infinitely, so time out (in ms) just in case. (We should see a StackOverflowException before then, though.)