Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #26 from stephen-palmer/master
Browse files Browse the repository at this point in the history
bugfix/bogus-quit-detected
  • Loading branch information
stephen-palmer authored Apr 13, 2018
2 parents 731d478 + 6fa8310 commit f228ea0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/server/client_stream_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ClientStreamProcessor extends Transform {
if(!fillBufferWithData()) {

// Quit?
if (data[data.length - 1] === CMD_QUIT) {
if (!readState.didParseCmd && data[data.length - 1] === CMD_QUIT) {
this.push('q');
}

Expand Down
5 changes: 5 additions & 0 deletions test/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ describe("Protocol", () => {

tests.forEach(function (test) {
it(`should store ${test.ext} data with a (${test.cmd}) command (client write packet size = ${test.packetSize})`, () => {
// Insert 'q' character ('Quit' command) into the GUID, to catch subtle protocol errors when packet size is 1
if(test.packetSize === 1) {
test.data.guid[0] = test.data.guid[test.data.guid.length - 1] = 'q'.charCodeAt(0);
}

const buf = Buffer.from(
encodeCommand(cmd.transactionStart, test.data.guid, test.data.hash) +
encodeCommand(test.cmd, null, null, test.data[test.ext]) +
Expand Down

0 comments on commit f228ea0

Please sign in to comment.