Skip to content

Commit

Permalink
Do not delay send/recv if timeout is 0 [fixes #381].
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Mar 19, 2020
1 parent 1cc6594 commit 210e94c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/module.h
Expand Up @@ -13,8 +13,8 @@
#include "util/trash.h"

#include <chrono>
#include <future>
#include <cstdio>
#include <future>

namespace zmq {
class Context;
Expand Down
4 changes: 2 additions & 2 deletions src/socket.cc
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 210e94c

Please sign in to comment.