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