Skip to content

Commit

Permalink
src: remove HasWriteQueue()
Browse files Browse the repository at this point in the history
Tests are passing without it, and this otherwise makes the
code harder to reason about because the `async` flag on the
write request object would not be set even though the callback
would still be pending.

PR-URL: nodejs#18019
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax committed Jan 14, 2018
1 parent 8b751f7 commit 20f6aae
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
13 changes: 3 additions & 10 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
}

err = DoWrite(req_wrap, buf_list, count, nullptr);
if (HasWriteQueue())
req_wrap_obj->Set(env->async(), True(env->isolate()));
req_wrap_obj->Set(env->async(), True(env->isolate()));

if (err)
req_wrap->Dispose();
Expand Down Expand Up @@ -254,8 +253,7 @@ int StreamBase::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
}

err = DoWrite(req_wrap, bufs, count, nullptr);
if (HasWriteQueue())
req_wrap_obj->Set(env->async(), True(env->isolate()));
req_wrap_obj->Set(env->async(), True(env->isolate()));
req_wrap_obj->Set(env->buffer_string(), args[1]);

if (err)
Expand Down Expand Up @@ -381,8 +379,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) {
reinterpret_cast<uv_stream_t*>(send_handle));
}

if (HasWriteQueue())
req_wrap_obj->Set(env->async(), True(env->isolate()));
req_wrap_obj->Set(env->async(), True(env->isolate()));

if (err)
req_wrap->Dispose();
Expand Down Expand Up @@ -476,10 +473,6 @@ int StreamResource::DoTryWrite(uv_buf_t** bufs, size_t* count) {
return 0;
}

bool StreamResource::HasWriteQueue() {
return true;
}


const char* StreamResource::Error() const {
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class StreamResource {
uv_buf_t* bufs,
size_t count,
uv_stream_t* send_handle) = 0;
virtual bool HasWriteQueue();
virtual const char* Error() const;
virtual void ClearError();

Expand Down
4 changes: 0 additions & 4 deletions src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ int LibuvStreamWrap::DoWrite(WriteWrap* w,
}


bool LibuvStreamWrap::HasWriteQueue() {
return stream()->write_queue_size > 0;
}


void LibuvStreamWrap::AfterUvWrite(uv_write_t* req, int status) {
WriteWrap* req_wrap = WriteWrap::from_req(req);
Expand Down
1 change: 0 additions & 1 deletion src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
uv_buf_t* bufs,
size_t count,
uv_stream_t* send_handle) override;
bool HasWriteQueue() override;

inline uv_stream_t* stream() const {
return stream_;
Expand Down

0 comments on commit 20f6aae

Please sign in to comment.