[Mono-dev] Potential issue with async sockets in Raspberry ARM – Mono 4.4.0
cswiedler at trionworlds.com
Fri Sep 9 16:11:41 UTC 2016
From what I understand it’s dangerous to do blocking reads on the callback from something like BeginReceive. The callback will happen on a threadpool thread, and the blocking reads could then cause the threadpool to be exhausted. I don’t know if that’s causing your specific problem (it could, if the reads really do block and you have enough of them) but it’s something to watch out for.
From: Mono-devel-list [mailto:mono-devel-list-bounces at lists.dot.net] On Behalf Of psantosl at codicesoftware.com
Sent: Friday, September 09, 2016 2:42 AM
To: mono-devel-list at lists.dot.net
Cc: dude <rdealba at codicesoftware.com>
Subject: [Mono-dev] Potential issue with async sockets in Raspberry ARM – Mono 4.4.0
I’m posting here hoping someone can throw some light into the problem. I'm a little bit lost now.
Our server code (Plastic SCM) running on Raspberry on Mono 4.4.0 (exact version below) ends up not awaking from socket.BeginReceive after a while.
I mean, client connects and requests data in 4MB chunks, and depending on the run, it can transfer a few GB but it ends up not awaking. The client just sits waiting on a “socket recv” but the server doesn’t answer. Connection is established (can be checked at OS level).
The code could be simplified as follows:
mSocket.BeginReceive(buffer, 0, 0, SocketFlags.None,
OnMessageReceived => does the EndReceive and then reads data and enqueues the request for a threadpool to attend it. Once the request is attented and the response sent, BeginReceive is invoked again. Important: all “BeginReceive()” calls are done from the same thread which NEVER dies.
All we use the BeginReceive for is to decouple socket from thread, so we do not have a 1-1. You see we do pass “zero” as bytes to read, because all we want to achieve is to get awakened when new data is received, then just read using blocking calls (no async).
I’m asking if there could be something about Mono because I read 4.6 release notes (http://www.mono-project.com/docs/about-mono/releases/4.6.0/) and the “atomic fixes for ARM64”. Could it be related somehow.
The same code runs on Windows and Linux PCs (even Macs) without issues. We use the same code on all our production servers and even our Cloud roles, and we are not aware of issues.
Now we are testing a new faster storage and using Raspberry to check how fast it goes on slower hardware.
Complete Mono version:
Mono JIT compiler version 4.4.0 (tarball Tue Jun 14 13:44:06 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com<http://www.mono-project.com>
LLVM: supported, not enabled.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list