Skip to content

Commit

Permalink
Sync with upstream (#31)
Browse files Browse the repository at this point in the history
* Massive perf boost

* 💥 fix travis tests: add pkg libssl-dev

• also update gcc to 4.9
• update libzmq to 4.1.4

Signed-off-by: Bent Cardan <bent@nothingsatisfies.com>

* Add unref/ref APIs to detach/attach sockets from/to the event loop.

 * This does not affect reference counting of internal Socket C++
   objects which is a subclass of ObjectWrap because unref() only
   temporarily disables the socket polling without adding/removing
   endpoints.

 * To avoid conflicts with ObjectWrap's Unref/Ref methods, I used
   explicit method names in the C++ side (e.g., DetachFromEventLoop)
   while keeping the Javascript-side names same to vanilla Sockets
   (e.g., unref).

 * When there is no endpoints, it automatically detaches the socket from
   the event loop to reduce polling overheads.  When there is one or
   more endpoints, it automatically re-attach the socket.

* Update README for unref/ref APIs.

 * Also fix some Markdown incompatibilities with 3rd party editors.

* Updated history

* State cleanup when (un)bindsync fails

Fixes #507

* History update

* Update history

* Skip curve export test if libsodium is missing (#509)

* Fixes batch isClosed check (#513)

* Bump NAN to 2.2.0 (#520)

* Release notes update

* Release 2.15.0

* Bump NAN to 2.3

This gets rid of deprecation warnings introduced in Node 6.

* Release 2.15.1

* Travis test on Node.js 6 (#530)

* Burst test for router/dealer (#529)

* Burst test for router/dealer

* Made burst-test multi-part

* Should fix missing incoming messages (#531)

* Should fix missing incoming messages

* Final fix

* Release

* This fixes burst sends on "req" sockets. (#536)

* This fixes burst sends on "req" sockets.

* Fix missing read flush triggered during send

* Release

* skip monitoring callback if socket has been closed (#540)
  • Loading branch information
lgeiger authored and rgbkrk committed Sep 10, 2016
1 parent 333c564 commit 0394c9d
Show file tree
Hide file tree
Showing 20 changed files with 254 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@ node_modules
Makefile.gyp
binding.Makefile
binding.target.gyp.mk
npm-debug.log
gyp-mac-tool
out/
zmq
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -6,9 +6,10 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- gcc-4.9
- g++-4.9
- uuid-dev
- libssl-dev

os:
- linux
Expand All @@ -31,7 +32,7 @@ before_install:
- nvm use $NODE_VERSION
- node --version
- npm --version
- test "$(uname)" = "Darwin" || export CXX=g++-4.8 CC=gcc-4.8
- test "$(uname)" = "Darwin" || export CXX=g++-4.9 CC=gcc-4.9
- gcc --version
- sh build_libzmq.sh

Expand Down
27 changes: 27 additions & 0 deletions History.md
@@ -1,3 +1,30 @@
2.15.3 / 2016-6-3
=================

* 2.15.0 introduced a bug where request sockets could no longer batch up requests.
This release should fix that [ronkorving, jaleigh]

2.15.2 / 2016-5-22
==================

* 2.15.0 introduced a bug where some messages would not be received. This release
should fix that [ronkorving]

2.15.1 / 2016-5-8
=================

* Node.js 6 compatibility (NAN 2.3) [kkoopa]

2.15.0 / 2016-4-27
==================

* Dropped support for Node 0.8 [reqshark]
* Added unref/ref APIs to detach/attach sockets from/to the event loop [Joongi Kim]
* Improved message throughput 3-fold on ZMQ 4 [ronkorving]
* When bind or unbind failed, you could never try again (fixed) [ronkorving]
* Various travis configuration improvements [reqshark]
* Bumped NAN to 2.2.x [JanStevens]

2.14.0 / 2015-11-20
===================

Expand Down
11 changes: 8 additions & 3 deletions test/exports.js
Expand Up @@ -9,18 +9,23 @@ describe('exports', function(){
});

it('should generate valid curve keypair', function(done) {
if (!semver.gte(zmq.version,'4.0.0') || require('os').platform() == 'win32'){
try {
var rep = zmq.socket('rep');
rep.curve_server = 0;
} catch(e) {
console.log("libsodium seems to be missing (skipping curve test)");
done();
return console.warn('Test requires libzmq >= 4 compiled with libsodium');
return;
}

var curve = zmq.curveKeypair();
should.exist(curve);
should.exist(curve.public);
should.exist(curve.secret);
curve.public.length.should.equal(40);
curve.secret.length.should.equal(40);
done();
});
});

it('should export socket types and options', function(){
// All versions.
Expand Down
26 changes: 26 additions & 0 deletions test/socket.error-callback.js
@@ -0,0 +1,26 @@

var zmq = require('..')
, should = require('should')
, semver = require('semver');

var version = semver.gte(zmq.version, '3.2.0');

describe('socket.error-callback', function(){
var sock;

if (!version) {
return console.warn("ZMQ_ROUTER_MANDATORY requires libzmq 3.2.0, skipping test");
}

it('should create a socket and set ZMQ_ROUTER_MANDATORY', function () {
sock = zmq.socket('router');
sock.setsockopt(zmq.ZMQ_ROUTER_MANDATORY, 1);
});

it('should callback with error when not connected', function (done) {
sock.send(['foo', 'bar'], null, function (error) {
error.should.be.an.instanceof(Error);
done();
});
});
});
11 changes: 6 additions & 5 deletions test/socket.events.js
@@ -1,6 +1,5 @@
var zmq = require('..')
, should = require('should')
, semver = require('semver');
, should = require('should');

describe('socket.events', function(){

Expand All @@ -14,18 +13,20 @@ describe('socket.events', function(){
rep.send('world');
});

rep.bind('inproc://stuff');
rep.bind('inproc://stuffevents', function (error) {
if (error) throw error;
});

rep.on('bind', function(){
req.connect('inproc://stuff');
req.send('hello');
req.connect('inproc://stuffevents');
req.on('message', function(msg){
msg.should.be.an.instanceof(Buffer);
msg.toString().should.equal('world');
req.close();
rep.close();
done();
});
req.send('hello');
});
});
});
15 changes: 10 additions & 5 deletions test/socket.messages.js
Expand Up @@ -31,7 +31,8 @@ describe('socket.messages', function(){
}
});

pull.bind('inproc://stuff_ssm', function(){
pull.bind('inproc://stuff_ssm', function (error) {
if (error) throw error;
push.connect('inproc://stuff_ssm');
push.send('string');
push.send(15.99);
Expand All @@ -49,7 +50,8 @@ describe('socket.messages', function(){
done();
});

pull.bind('inproc://stuff_ssmm', function(){
pull.bind('inproc://stuff_ssmm', function (error) {
if (error) throw error;
push.connect('inproc://stuff_ssmm');
push.send(['string', 15.99, new Buffer('buffer')]);
});
Expand All @@ -67,7 +69,8 @@ describe('socket.messages', function(){
done();
});

pull.bind('inproc://stuff_sss', function(){
pull.bind('inproc://stuff_sss', function (error) {
if (error) throw error;
push.connect('inproc://stuff_sss');
push.send(['tobi', 'loki'], zmq.ZMQ_SNDMORE);
push.send(['jane', 'luna'], zmq.ZMQ_SNDMORE);
Expand Down Expand Up @@ -104,7 +107,8 @@ describe('socket.messages', function(){
pull.setsockopt(zmq.ZMQ_HWM, 1);
}

push.bind('tcp://127.0.0.1:12345', function () {
push.bind('tcp://127.0.0.1:12345', function (error) {
if (error) throw error;
push.send('string');
push.send(15.99);
push.send(new Buffer('buffer'));
Expand All @@ -129,7 +133,8 @@ describe('socket.messages', function(){
}
});

pull.bind('inproc://stuff_ssmm', function(){
pull.bind('inproc://stuff_ssmm', function (error) {
if (error) throw error;
push.connect('inproc://stuff_ssmm');

push.send('hello', null, cb);
Expand Down
4 changes: 3 additions & 1 deletion test/socket.monitor.js
Expand Up @@ -41,7 +41,9 @@ describe('socket.monitor', function() {
// enable monitoring for this socket
rep.monitor();

rep.bind('tcp://127.0.0.1:5423');
rep.bind('tcp://127.0.0.1:5423', function (error) {
if (error) throw error;
});

rep.on('bind', function(){
req.connect('tcp://127.0.0.1:5423');
Expand Down
16 changes: 9 additions & 7 deletions test/socket.pair.js
@@ -1,6 +1,5 @@
var zmq = require('..')
, should = require('should')
, semver = require('semver');
, should = require('should');

describe('socket.pair', function(){

Expand All @@ -9,8 +8,9 @@ describe('socket.pair', function(){
, pairC = zmq.socket('pair');

var n = 0;
pairB.on('message', function (msg){
pairB.on('message', function (msg) {
msg.should.be.an.instanceof(Buffer);

switch (n++) {
case 0:
msg.toString().should.equal('foo');
Expand All @@ -27,14 +27,16 @@ describe('socket.pair', function(){
}
});

pairC.on('message', function (msg){
pairC.on('message', function (msg) {
msg.should.be.an.instanceof(Buffer);
msg.toString().should.equal('barnacle');
})

var addr = "inproc://stuff";
var addr = "inproc://stuffpair";

pairB.bind(addr, function (error) {
if (error) throw error;

pairB.bind(addr, function(){
pairC.connect(addr);
pairB.send('barnacle');
pairC.send('foo');
Expand All @@ -43,4 +45,4 @@ describe('socket.pair', function(){
});
});

});
});
6 changes: 4 additions & 2 deletions test/socket.pub-sub.js
Expand Up @@ -34,7 +34,8 @@ describe('socket.pub-sub', function(){

var addr = "inproc://stuff_ssps";

sub.bind(addr, function(){
sub.bind(addr, function (error) {
if (error) throw error;
pub.connect(addr);

// The connect is asynchronous, and messages published to a non-
Expand Down Expand Up @@ -75,7 +76,8 @@ describe('socket.pub-sub', function(){
}
});

sub.bind('inproc://stuff_sspsf', function(){
sub.bind('inproc://stuff_sspsf', function (error) {
if (error) throw error;
pub.connect('inproc://stuff_sspsf');

// See comments on pub-sub test.
Expand Down
12 changes: 8 additions & 4 deletions test/socket.push-pull.js
Expand Up @@ -29,7 +29,8 @@ describe('socket.push-pull', function(){

var addr = "inproc://stuff";

pull.bind(addr, function(){
pull.bind(addr, function (error) {
if (error) throw error;
push.connect(addr);

push.send('foo');
Expand All @@ -56,7 +57,8 @@ describe('socket.push-pull', function(){

var addr = "inproc://pause_stuff";

pull.bind(addr, function(){
pull.bind(addr, function (error) {
if (error) throw error;
push.connect(addr);

push.send('foo');
Expand All @@ -79,7 +81,8 @@ describe('socket.push-pull', function(){
var addr = "inproc://pause_stuff";

var messages = ['bar', 'foo'];
pull.bind(addr, function(){
pull.bind(addr, function (error) {
if (error) throw error;
push.connect(addr);

pull.pause()
Expand Down Expand Up @@ -132,7 +135,8 @@ describe('socket.push-pull', function(){

var addr = "inproc://resume_stuff";

pull.bind(addr, function(){
pull.bind(addr, function (error) {
if (error) throw error;
push.connect(addr);
pull.pause()

Expand Down
47 changes: 42 additions & 5 deletions test/socket.req-rep.js
@@ -1,6 +1,5 @@
var zmq = require('..')
, should = require('should')
, semver = require('semver');
, should = require('should');

describe('socket.req-rep', function(){
it('should support req-rep', function(done){
Expand All @@ -13,8 +12,9 @@ describe('socket.req-rep', function(){
rep.send('world');
});

rep.bind('inproc://stuff', function(){
req.connect('inproc://stuff');
rep.bind('inproc://stuffreqrep', function (error) {
if (error) throw error;
req.connect('inproc://stuffreqrep');
req.send('hello');
req.on('message', function(msg){
msg.should.be.an.instanceof(Buffer);
Expand All @@ -40,7 +40,8 @@ describe('socket.req-rep', function(){
rep.send('world');
});

rep.bind('inproc://' + n, function(){
rep.bind('inproc://' + n, function (error) {
if (error) throw error;
req.connect('inproc://' + n);
req.send('hello');
req.on('message', function(msg){
Expand All @@ -55,4 +56,40 @@ describe('socket.req-rep', function(){
}
});

it('should support a burst', function (done) {
var rep = zmq.socket('rep');
var req = zmq.socket('req');
var n = 10;

rep.on('message', function (msg) {
msg.should.be.an.instanceof(Buffer);
msg.toString().should.equal('hello');
rep.send('world');
});

rep.bind('inproc://reqrepburst', function (error) {
if (error) throw error;
req.connect('inproc://reqrepburst');

var received = 0;

req.on('message', function(msg){
msg.should.be.an.instanceof(Buffer);
msg.toString().should.equal('world');

received += 1;

if (received === n) {
rep.close();
req.close();
done();
}
});

for (var i = 0; i < n; i += 1) {
req.send('hello');
}
});
});

});

0 comments on commit 0394c9d

Please sign in to comment.