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

Try catch for blocking recieve which can throw #1087

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/NetMQ/Core/Mailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Diagnostics;
using System.Net.Sockets;
using NetMQ.Core.Utils;
Expand Down Expand Up @@ -208,8 +209,17 @@ public bool TryRecv(int timeout, out Command command)
return true;

// If there are no more commands available, switch into passive state.
m_active = false;
m_signaler.Recv();
try
{
m_active = false;
m_signaler.Recv();
}
catch
{
m_active = true;
command = default(Command);
return false;
}
}

// Wait for signal from the command sender.
Expand Down
Loading