From 453008d73ef7248c809d4d1b52c127915b08fc46 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 9 Dec 2017 05:29:11 +0100 Subject: src: minor refactoring to StreamBase writes Instead of having per-request callbacks, always call a callback on the `StreamBase` instance itself for `WriteWrap` and `ShutdownWrap`. This makes `WriteWrap` cleanup consistent for all stream classes, since the after-write callback is always the same now. If special handling is needed for writes that happen to a sub-class, `AfterWrite` can be overridden by that class, rather than that class providing its own callback (e.g. updating the write queue size for libuv streams). If special handling is needed for writes that happen on another stream instance, the existing `after_write_cb()` callback is used for that (e.g. custom code after writing to the transport from a TLS stream). As a nice bonus, this also makes `WriteWrap` and `ShutdownWrap` instances slightly smaller. PR-URL: https://github.com/nodejs/node/pull/17564 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell --- src/tls_wrap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tls_wrap.h') diff --git a/src/tls_wrap.h b/src/tls_wrap.h index edd21cf1cf..87eac75779 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -111,7 +111,7 @@ class TLSWrap : public AsyncWrap, static void SSLInfoCallback(const SSL* ssl_, int where, int ret); void InitSSL(); void EncOut(); - static void EncOutCb(WriteWrap* req_wrap, int status); + void EncOutAfterWrite(WriteWrap* req_wrap, int status); bool ClearIn(); void ClearOut(); void MakePending(); @@ -134,7 +134,7 @@ class TLSWrap : public AsyncWrap, uint32_t UpdateWriteQueueSize(uint32_t write_queue_size = 0); // Resource implementation - static void OnAfterWriteImpl(WriteWrap* w, void* ctx); + static void OnAfterWriteImpl(WriteWrap* w, int status, void* ctx); static void OnAllocImpl(size_t size, uv_buf_t* buf, void* ctx); static void OnReadImpl(ssize_t nread, const uv_buf_t* buf, -- cgit v1.2.3