mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
handle sequence overflow (more than 65535 requests in one connection)
This commit is contained in:
parent
86152f7aaf
commit
2decda57fd
3 changed files with 51 additions and 3 deletions
|
|
@ -92,8 +92,15 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
|
||||||
target[r] = (function(reqName) {
|
target[r] = (function(reqName) {
|
||||||
|
|
||||||
var reqFunc = function req_proxy() {
|
var reqFunc = function req_proxy() {
|
||||||
client.seq_num++; // TODO: handle overflow (seq should be last 15 (?) bits of the number
|
|
||||||
|
// simple overflow handling (this means that currently there is no way to have more than 65535 requests in the queue
|
||||||
|
// TODO: edge cases testing
|
||||||
|
if (client.seq_num == 65535)
|
||||||
|
client.seq_num = 0;
|
||||||
|
else
|
||||||
|
client.seq_num++;
|
||||||
|
|
||||||
|
// long stack traces. going to disable in next commit, keep it currently to compare performance
|
||||||
var err = new Error;
|
var err = new Error;
|
||||||
err.name = reqName;
|
err.name = reqName;
|
||||||
Error.captureStackTrace(err, arguments.callee);
|
Error.captureStackTrace(err, arguments.callee);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
, "description": "A pure node.js JavaScript client implementing X Window (X11) protocol."
|
, "description": "A pure node.js JavaScript client implementing X Window (X11) protocol."
|
||||||
, "keywords": ["X Window", "ui", "gui", "widgets", "desktop", "XWindow", "X"]
|
, "keywords": ["X Window", "ui", "gui", "widgets", "desktop", "XWindow", "X"]
|
||||||
, "homepage": "https://github.com/sidorares/node-x11"
|
, "homepage": "https://github.com/sidorares/node-x11"
|
||||||
, "version" : "0.0.7"
|
, "version" : "0.0.8"
|
||||||
, "maintainers" :
|
, "maintainers" :
|
||||||
[ { "name": "Andrey Sidorov"
|
[ { "name": "Andrey Sidorov"
|
||||||
, "email": "sidoares@yandex.ru"
|
, "email": "sidoares@yandex.ru"
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
"should": "*"
|
"should": "*"
|
||||||
}
|
}
|
||||||
, "scripts": {
|
, "scripts": {
|
||||||
"test": "mocha",
|
"test": "mocha -t 30000",
|
||||||
"prepublish" : "npm prune"
|
"prepublish" : "npm prune"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
41
test/sequence-overflow.js
Normal file
41
test/sequence-overflow.js
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
var should = require('should');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
|
describe('Client', function() {
|
||||||
|
|
||||||
|
var display;
|
||||||
|
beforeEach(function(done) {
|
||||||
|
var client = x11.createClient(function(dpy) {
|
||||||
|
display=dpy;
|
||||||
|
done();
|
||||||
|
client.removeListener('error', done);
|
||||||
|
});
|
||||||
|
client.on('error', done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle more than 65535 requests in one connection', function(done) {
|
||||||
|
should.exist(display);
|
||||||
|
should.exist(display.screen);
|
||||||
|
var total = 70000;
|
||||||
|
var left = total;
|
||||||
|
var start = Date.now();
|
||||||
|
function test(err, str) {
|
||||||
|
if (err)
|
||||||
|
return done(err);
|
||||||
|
|
||||||
|
if (left == 0) {
|
||||||
|
var end = Date.now();
|
||||||
|
var dur = end - start;
|
||||||
|
console.log(total + ' requests finished in ' + dur + ' ms, ' + 1000*total/dur + ' req/sec');
|
||||||
|
return done();
|
||||||
|
}
|
||||||
|
left--;
|
||||||
|
display.client.GetAtomName(1, test);
|
||||||
|
}
|
||||||
|
|
||||||
|
left++;
|
||||||
|
test(); // first call starts sequens and not a callback from GetAtomName, thus left++
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue