workers: payload length.

This commit is contained in:
Christopher Jeffrey 2016-07-28 11:06:42 -07:00
parent e709cbeae5
commit a0e0ecdd73
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -531,13 +531,11 @@ Worker.prototype.destroy = function destroy() {
Worker.prototype.execute = function execute(method, args, timeout, callback) {
var self = this;
var job = this.uid++;
var job = this.uid;
var event, timer;
if (job > 0xffffffff) {
if (++this.uid === 0x100000000)
this.uid = 0;
job = this.uid++;
}
event = 'response ' + job;
@ -849,7 +847,7 @@ Framer.prototype.packet = function packet(job, cmd, items) {
packet.writeUInt32LE(job, 4, true);
packet.writeUInt8(cmd.length, 8, true);
packet.write(cmd, 9, 'ascii');
packet.writeUInt32LE(payload.length + 1, 21, true);
packet.writeUInt32LE(payload.length, 21, true);
payload.copy(packet, 25);
packet[packet.length - 1] = 0x0a;
@ -1023,9 +1021,9 @@ Parser.prototype.read = function read(size) {
};
Parser.prototype.parse = function parse(data) {
var packet;
var packet = this.packet;
if (!this.packet) {
if (!packet) {
try {
packet = this.parseHeader(data);
} catch (e) {
@ -1034,13 +1032,11 @@ Parser.prototype.parse = function parse(data) {
}
this.packet = packet;
this.waiting = packet.size;
this.waiting = packet.size + 1;
return;
}
packet = this.packet;
this.waiting = 25;
this.packet = null;