提交 936c28ad 编写于 作者: G Gonzalo Paniagua Javier

Handle special case when disposing a socket.

	When disposing a socket that has more than one asynchronous read/write
	pending, one of the callbacks could call DisposeAllOnClose() while
	another one is waiting on the lock. Once the lock is acquired,
	queue.Count will be 0 and Dequeue would fail.
	This if fixed now.

	Fixes bug #645675.
上级 9f62005c
......@@ -236,7 +236,11 @@ namespace System.Net.Sockets {
SocketAsyncCall sac = null;
SocketAsyncResult req = null;
lock (queue) {
queue.Dequeue (); // remove ourselves
// queue.Count will only be 0 if the socket is closed while receive/send
// operation(s) are pending and at least one call to this method is
// waiting on the lock while another one calls CompleteAllOnDispose()
if (queue.Count > 0)
queue.Dequeue (); // remove ourselves
if (queue.Count > 0) {
worker = (Worker) queue.Peek ();
if (!Sock.disposed) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册