Bug in the dispatching of OnConnectionClosed() in release 5.2.4 of the server framework

A client has just reported a bug in version 5.2.4 of The Server Framework. The bug has, possibly, been present since 5.2.2 and relates to the dispatch of OnConnectionClosed() callbacks when a socket is released.

If a socket is still valid, i.e. it hasn’t been previously closed, when the socket is released for the last time then part of the clean up is to close the socket. Your code is informed of this by the OnConnectionClosed() callback being called. However, if this callback IS called as part of socket clean up then you can’t call AddRef() on the socket that you’re passed in OnConnectionClosed() and the socket will throw an exception because the reference count is being incremented from zero.

There will shortly be a 5.2.5 release which fixes this.