Skip to content

Commit 915223d

Browse files
authored
Merge pull request #1087 from tmatthey/pr/signal-tryrec
Try catch for blocking recieve which can throw
2 parents 041077f + e8a6405 commit 915223d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/NetMQ/Core/Mailbox.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ You should have received a copy of the GNU Lesser General Public License
1919
along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
using System;
2223
using System.Diagnostics;
2324
using System.Net.Sockets;
2425
using NetMQ.Core.Utils;
@@ -208,8 +209,17 @@ public bool TryRecv(int timeout, out Command command)
208209
return true;
209210

210211
// If there are no more commands available, switch into passive state.
211-
m_active = false;
212-
m_signaler.Recv();
212+
try
213+
{
214+
m_active = false;
215+
m_signaler.Recv();
216+
}
217+
catch
218+
{
219+
m_active = true;
220+
command = default(Command);
221+
return false;
222+
}
213223
}
214224

215225
// Wait for signal from the command sender.

0 commit comments

Comments
 (0)