Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recieve handler thread pinned at 100% #73

Closed
Charlese2 opened this issue Mar 2, 2024 · 1 comment · Fixed by #74
Closed

Recieve handler thread pinned at 100% #73

Charlese2 opened this issue Mar 2, 2024 · 1 comment · Fixed by #74

Comments

@Charlese2
Copy link
Contributor

Charlese2 commented Mar 2, 2024

The ReceiveHandler will just spin if the remote closes the connection as Socket.Receive() just returns immediately with 0 bytes instead of blocking.

int bytesReveived = _socket.Receive(readBuffer);

https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.receive?view=net-6.0#system-net-sockets-socket-receive(system-byte())

If you are using a connection-oriented Socket, the Receive method will read as much data as is available, up to the size of the buffer. If the remote host shuts down the Socket connection with the Shutdown method, and all available data has been received, the Receive method will complete immediately and return zero bytes.

@Charlese2 Charlese2 changed the title Recieve handler thread pinned at 100 Recieve handler thread pinned at 100% Mar 2, 2024
@Charlese2
Copy link
Contributor Author

image
Most of the time the cpu seems to be in the kernel code of the recvmsg syscall while it is spinning in the while loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant