andalera / retlang

Automatically exported from code.google.com/p/retlang
0 stars 3 forks source link

Race condition in Channel.NumSubscribers #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Line 119 of Channel.cs is:

get { return _subscribers == null ? 0 : 
_subscribers.GetInvocationList().Length; }

This will throw a NullReferenceException if ClearSubscribers() is called on 
another thread while NumSubscribers is executing. I suggest changing this to:

get {
event Action<T> safeSubscribers = _subscribers;
return safeSubscribers == null ? 0 : safeSubscribers.GetInvocationList().Length;
}

Original issue reported on code.google.com by foo...@gmail.com on 18 May 2011 at 8:42

GoogleCodeExporter commented 8 years ago
NumSubscribers is not on the IChannel<T> interface and therefore is intended 
for testing.  However, it is an easy fix, so I checked it in.  It will be 
available in the next release.  Thanks for the submission.

Original comment by graham.m...@gmail.com on 18 May 2011 at 8:53