[Mono-list] a different delegate problem...

Simon Waite simon@psionics.demon.co.uk
Tue, 31 Dec 2002 03:38:57 -0000

** (Net.Tetracite.IrcClient.exe:19930): WARNING **: _wapi_handle_new: Ran
out of handles!
** (Net.Tetracite.IrcClient.exe:19930): WARNING **: _wapi_handle_new: Seeing
if GC collection helps...
** (Net.Tetracite.IrcClient.exe:19999): WARNING **: _wapi_handle_new: Ran
out of handles!
** (Net.Tetracite.IrcClient.exe:19999): WARNING **: _wapi_handle_new: Seeing
if GC collection helps...

(this goes on a bit - then bombs out with ...)

Unhandled Exception: System.Threading.SynchronizationLockException: The
current thread does not own the lock
in <0x00081> 00 System.Threading.Monitor:Exit (object)
in <0x00042> 00 System.Threading.Thread:clr_state
in <0x0005b> 00 System.Threading.Thread:Start ()
in <0x000e6> 00 System.Net.Sockets.Socket:BeginReceive
in <0x00066> 00 Net.Tetracite.Irc.BaseIrcClient:regRx ()
in <0x00187> 00 Net.Tetracite.Irc.BaseIrcClient:ReadCallBack
in <0x00061> 01 System.MulticastDelegate:invoke_void_IAsyncResult
in <0x0007d> 00 .Worker:End ()
in <0x00061> 00 .Worker:Receive ()
in <0x0005b> 01 System.MulticastDelegate:invoke_void ()

Basically what is happening here is I'm async reading from a socket, one
byte at a time.
I know this is suboptimal, but it works on .NET for the time being.

"RegRx" sets up the callback to ReadCallBack.

ReadCallBack calls RegRx to reregister its interest every read.

socket.BeginReceive( buffer,0,1,SocketFlags.None,new
AsyncCallback(this.ReadCallBack),null );

Having now seen the repeated calls to  new AsyncCallback() I don't
repeatedly create that object,
but the result is much the same, it runs out of handles, and then dies,
though where exactly it dies
appears non-deterministic.

Mono Version 0.17 - from alps stable debs.