From 210e94c87e75f6efe33d119d83a072269957f963 Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Thu, 19 Mar 2020 15:35:40 +0100 Subject: [PATCH] Do not delay send/recv if timeout is 0 [fixes #381]. --- src/module.h | 2 +- src/socket.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/module.h b/src/module.h index 36dd2ee8..fb6451ee 100644 --- a/src/module.h +++ b/src/module.h @@ -13,8 +13,8 @@ #include "util/trash.h" #include -#include #include +#include namespace zmq { class Context; diff --git a/src/socket.cc b/src/socket.cc index 95f8d3ae..bafd86f2 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -548,7 +548,7 @@ Napi::Value Socket::Send(const Napi::CallbackInfo& info) { #ifdef ZMQ_NO_SYNC_RESOLVE Warn(Env(), "Promise resolution by send() is delayed (ZMQ_NO_SYNC_RESOLVE)."); #else - if (sync_operations++ < max_sync_operations) { + if (send_timeout == 0 || sync_operations++ < max_sync_operations) { auto res = Napi::Promise::Deferred::New(Env()); Send(res, parts); @@ -592,7 +592,7 @@ Napi::Value Socket::Receive(const Napi::CallbackInfo& info) { #ifdef ZMQ_NO_SYNC_RESOLVE Warn(Env(), "Promise resolution by receive() is delayed (ZMQ_NO_SYNC_RESOLVE)."); #else - if (sync_operations++ < max_sync_operations) { + if (receive_timeout == 0 || sync_operations++ < max_sync_operations) { auto res = Napi::Promise::Deferred::New(Env()); Receive(res);