-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Pri3Indicates issues/PRs that are low priorityIndicates issues/PRs that are low priorityarea-System.Net.SocketsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
#8337 fixed one StackOverflow case when accepting new connections, there is another opportunity for stack overflow in the mutual recursion of ProcessSend
and ProcessReceive
functions
Lines 318 to 364 in dcc2e40
private void ProcessReceive(SocketAsyncEventArgs e) | |
{ | |
// check if the remote host closed the connection | |
AsyncUserToken token = (AsyncUserToken)e.UserToken; | |
if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success) | |
{ | |
//increment the count of the total bytes receive by the server | |
Interlocked.Add(ref m_totalBytesRead, e.BytesTransferred); | |
Console.WriteLine("The server has read a total of {0} bytes", m_totalBytesRead); | |
//echo the data received back to the client | |
e.SetBuffer(e.Offset, e.BytesTransferred); | |
bool willRaiseEvent = token.Socket.SendAsync(e); | |
if (!willRaiseEvent) | |
{ | |
ProcessSend(e); | |
} | |
} | |
else | |
{ | |
CloseClientSocket(e); | |
} | |
} | |
// This method is invoked when an asynchronous send operation completes. | |
// The method issues another receive on the socket to read any additional | |
// data sent from the client | |
// | |
// <param name="e"></param> | |
private void ProcessSend(SocketAsyncEventArgs e) | |
{ | |
if (e.SocketError == SocketError.Success) | |
{ | |
// done echoing data back to the client | |
AsyncUserToken token = (AsyncUserToken)e.UserToken; | |
// read the next block of data send from the client | |
bool willRaiseEvent = token.Socket.ReceiveAsync(e); | |
if (!willRaiseEvent) | |
{ | |
ProcessReceive(e); | |
} | |
} | |
else | |
{ | |
CloseClientSocket(e); | |
} | |
} |
Metadata
Metadata
Assignees
Labels
Pri3Indicates issues/PRs that are low priorityIndicates issues/PRs that are low priorityarea-System.Net.SocketsuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner