Skip to content

Commit f17987b

Browse files
committed
src: remove HasWriteQueue()
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: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent cf0b95c commit f17987b

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

src/stream_base.cc

+3-10
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
195195
}
196196

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

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

256255
err = DoWrite(req_wrap, bufs, count, nullptr);
257-
if (HasWriteQueue())
258-
req_wrap_obj->Set(env->async(), True(env->isolate()));
256+
req_wrap_obj->Set(env->async(), True(env->isolate()));
259257
req_wrap_obj->Set(env->buffer_string(), args[1]);
260258

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

384-
if (HasWriteQueue())
385-
req_wrap_obj->Set(env->async(), True(env->isolate()));
382+
req_wrap_obj->Set(env->async(), True(env->isolate()));
386383

387384
if (err)
388385
req_wrap->Dispose();
@@ -476,10 +473,6 @@ int StreamResource::DoTryWrite(uv_buf_t** bufs, size_t* count) {
476473
return 0;
477474
}
478475

479-
bool StreamResource::HasWriteQueue() {
480-
return true;
481-
}
482-
483476

484477
const char* StreamResource::Error() const {
485478
return nullptr;

src/stream_base.h

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ class StreamResource {
162162
uv_buf_t* bufs,
163163
size_t count,
164164
uv_stream_t* send_handle) = 0;
165-
virtual bool HasWriteQueue();
166165
virtual const char* Error() const;
167166
virtual void ClearError();
168167

src/stream_wrap.cc

-4
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,6 @@ int LibuvStreamWrap::DoWrite(WriteWrap* w,
380380
}
381381

382382

383-
bool LibuvStreamWrap::HasWriteQueue() {
384-
return stream()->write_queue_size > 0;
385-
}
386-
387383

388384
void LibuvStreamWrap::AfterUvWrite(uv_write_t* req, int status) {
389385
WriteWrap* req_wrap = WriteWrap::from_req(req);

src/stream_wrap.h

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
5555
uv_buf_t* bufs,
5656
size_t count,
5757
uv_stream_t* send_handle) override;
58-
bool HasWriteQueue() override;
5958

6059
inline uv_stream_t* stream() const {
6160
return stream_;

0 commit comments

Comments
 (0)