Skip to content

Commit

Permalink
Merge pull request #1087 from tmatthey/pr/signal-tryrec
Browse files Browse the repository at this point in the history
Try catch for blocking recieve which can throw
  • Loading branch information
drewnoakes committed May 12, 2024
2 parents 041077f + e8a6405 commit 915223d
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 915223d

Please sign in to comment.