Skip to content

Commit

Permalink
fix(packages/bindings#write): do not call native binding for empty bu…
Browse files Browse the repository at this point in the history
…ffers
  • Loading branch information
HipsterBrown committed Nov 5, 2018
1 parent f70d672 commit d347f3b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
17 changes: 10 additions & 7 deletions packages/bindings/lib/darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ class DarwinBinding extends AbstractBinding {
}

write(buffer) {
this.writeOperation = super
.write(buffer)
.then(() => unixWrite.call(this, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
if (buffer.length > 0) {
this.writeOperation = super
.write(buffer)
.then(() => unixWrite.call(this, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
}
return Promise.resolve()
}

update(options) {
Expand Down
17 changes: 10 additions & 7 deletions packages/bindings/lib/linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ class LinuxBinding extends AbstractBinding {
}

write(buffer) {
this.writeOperation = super
.write(buffer)
.then(() => unixWrite.call(this, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
if (buffer.length > 0) {
this.writeOperation = super
.write(buffer)
.then(() => unixWrite.call(this, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
}
return Promise.resolve()
}

update(options) {
Expand Down
17 changes: 10 additions & 7 deletions packages/bindings/lib/win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ class WindowsBinding extends AbstractBinding {
}

write(buffer) {
this.writeOperation = super
.write(buffer)
.then(() => promisify(binding.write)(this.fd, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
if (buffer.length > 0) {
this.writeOperation = super
.write(buffer)
.then(() => promisify(binding.write)(this.fd, buffer))
.then(() => {
this.writeOperation = null
})
return this.writeOperation
}
return Promise.resolve()
}

update(options) {
Expand Down

0 comments on commit d347f3b

Please sign in to comment.