Commit f648fb83 authored by Linshizhi's avatar Linshizhi

fix two step write bug cause of write 0 length data

parent 3921fdac
...@@ -401,12 +401,12 @@ export class Channel { ...@@ -401,12 +401,12 @@ export class Channel {
this.#readPointerCache = this.#getReadPointer(); this.#readPointerCache = this.#getReadPointer();
if (!this.#isAbleToWrite(size)) { if (!this.#isAbleToWrite(size) || size == 0) {
return []; return [];
} }
if (this.#writePhase != WRITE_PHASE.NO_STEP_WRITE) if (this.#writePhase != WRITE_PHASE.NO_STEP_WRITE)
throw new Error("Unable to call multiple writeStep1() consecutively") throw new Error("Unable to call multiple writeStep1()");
this.#writePhase = WRITE_PHASE.WAIT_CALLER_WRITE; this.#writePhase = WRITE_PHASE.WAIT_CALLER_WRITE;
let schedule = this.#cpySchedule(size); let schedule = this.#cpySchedule(size);
...@@ -431,12 +431,13 @@ export class Channel { ...@@ -431,12 +431,13 @@ export class Channel {
if (endPos != undefined) if (endPos != undefined)
this.#writePhaseEndPos = endPos; this.#writePhaseEndPos = endPos;
return buffers; return buffers;
} }
writeStep2() { writeStep2() {
if (this.#writePhase != WRITE_PHASE.WAIT_CALLER_WRITE) if (this.#writePhase != WRITE_PHASE.WAIT_CALLER_WRITE)
return; throw new Error("Have to call writeStep1() first")
this.#writePointerUpdate(this.#writePhaseEndPos); this.#writePointerUpdate(this.#writePhaseEndPos);
this.#writePhase = WRITE_PHASE.NO_STEP_WRITE; this.#writePhase = WRITE_PHASE.NO_STEP_WRITE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment