@@ -240,7 +240,7 @@ int SelectALPNCallback(
240240unsigned int inlen,
241241void * arg) {
242242 TLSWrap* w = static_cast <TLSWrap*>(SSL_get_app_data (s));
243- if (w->alpn_callback_enabled_ ) {
243+ if (w->get_alpn_callback_enabled () ) {
244244 Environment* env = w->env ();
245245 HandleScope handle_scope (env->isolate ());
246246
@@ -275,7 +275,7 @@ int SelectALPNCallback(
275275return SSL_TLSEXT_ERR_OK ;
276276 }
277277
278- const std::vector< unsigned char > & alpn_protos = w->alpn_protos_ ;
278+ auto & alpn_protos = w->get_alpn_protos () ;
279279
280280if (alpn_protos.empty ()) return SSL_TLSEXT_ERR_NOACK ;
281281
@@ -403,9 +403,9 @@ TLSWrap::TLSWrap(Environment* env,
403403StreamBase (env),
404404 env_(env),
405405 kind_(kind),
406- sc_(sc),
407- has_active_write_issued_by_prev_listener_(
408- under_stream_ws == UnderlyingStreamWriteStatus::kHasActive ) {
406+ sc_(sc) {
407+ flags_. has_active_write_issued_by_prev_listener =
408+ under_stream_ws == UnderlyingStreamWriteStatus::kHasActive ;
409409MakeWeak ();
410410CHECK (sc_);
411411 ssl_ = sc_->CreateSSL ();
@@ -444,8 +444,7 @@ SSL_SESSION* TLSWrap::ReleaseSession() {
444444
445445void TLSWrap::InvokeQueued (int status, const char * error_str) {
446446Debug (this , " Invoking queued write callbacks (%d, %s)" , status, error_str);
447- if (!write_callback_scheduled_)
448- return ;
447+ if (!flags_.write_callback_scheduled ) return ;
449448
450449if (current_write_) {
451450 BaseObjectPtr<AsyncWrap> current_write = std::move (current_write_);
@@ -465,8 +464,8 @@ void TLSWrap::NewSessionDoneCb() {
465464bool TLSWrap::OnEarlyClientHello (const unsigned char * session_id,
466465size_t session_id_len,
467466bool has_ticket) {
468- if (!hello_emitted_ ) {
469- hello_emitted_ = true ;
467+ if (!flags_. hello_emitted ) {
468+ flags_. hello_emitted = true ;
470469Debug (this , " Scheduling onclienthello" );
471470
472471// The hello data is only valid inside the library callback, and JS must
@@ -480,7 +479,7 @@ bool TLSWrap::OnEarlyClientHello(const unsigned char* session_id,
480479if (ssl_) EmitClientHello (id, has_ticket);
481480 });
482481 }
483- return hello_answered_ ;
482+ return flags_. hello_answered ;
484483}
485484
486485void TLSWrap::EmitClientHello (const std::vector<unsigned char >& session_id,
@@ -658,8 +657,8 @@ void TLSWrap::Start(const FunctionCallbackInfo<Value>& args) {
658657 TLSWrap* wrap;
659658ASSIGN_OR_RETURN_UNWRAP (&wrap, args.This ());
660659
661- CHECK (!wrap->started_ );
662- wrap->started_ = true ;
660+ CHECK (!wrap->flags_ . started );
661+ wrap->flags_ . started = true ;
663662
664663// Send ClientHello handshake
665664CHECK (wrap->is_client ());
@@ -703,7 +702,7 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
703702CHECK (!SSL_renegotiate_pending (ssl));
704703 Local<Value> callback;
705704
706- c->established_ = true ;
705+ c->flags_ . established = true ;
707706
708707if (object->Get (env->context (), env->onhandshakedone_string ())
709708 .ToLocal (&callback) && callback->IsFunction ()) {
@@ -727,17 +726,17 @@ void TLSWrap::EncOut() {
727726return ;
728727 }
729728
730- if (has_active_write_issued_by_prev_listener_ ) [[unlikely]] {
729+ if (flags_. has_active_write_issued_by_prev_listener ) [[unlikely]] {
731730Debug (this ,
732731" Returning from EncOut(), "
733732" has_active_write_issued_by_prev_listener_ is true" );
734733return ;
735734 }
736735
737736// Split-off queue
738- if (established_ && current_write_) {
737+ if (flags_. established && current_write_) {
739738Debug (this , " EncOut() write is scheduled" );
740- write_callback_scheduled_ = true ;
739+ flags_. write_callback_scheduled = true ;
741740 }
742741
743742if (ssl_ == nullptr ) {
@@ -750,7 +749,7 @@ void TLSWrap::EncOut() {
750749Debug (this , " No pending encrypted output" );
751750if (!pending_cleartext_input_ ||
752751 pending_cleartext_input_->ByteLength () == 0 ) {
753- if (!in_dowrite_ ) {
752+ if (!flags_. in_dowrite ) {
754753Debug (this , " No pending cleartext input, not inside DoWrite()" );
755754InvokeQueued (0 );
756755 } else {
@@ -805,7 +804,7 @@ void TLSWrap::EncOut() {
805804void TLSWrap::OnStreamAfterWrite (WriteWrap* req_wrap, int status) {
806805Debug (this , " OnStreamAfterWrite(status = %d)" , status);
807806
808- if (has_active_write_issued_by_prev_listener_ ) [[unlikely]] {
807+ if (flags_. has_active_write_issued_by_prev_listener ) [[unlikely]] {
809808Debug (this , " Notify write finish to the previous_listener_" );
810809CHECK_EQ (write_size_, 0 ); // we must have restrained writes
811810
@@ -830,7 +829,7 @@ void TLSWrap::OnStreamAfterWrite(WriteWrap* req_wrap, int status) {
830829
831830// Handle error
832831if (status) {
833- if (shutdown_ ) {
832+ if (flags_. shutdown ) {
834833Debug (this , " Ignoring error after shutdown" );
835834return ;
836835 }
@@ -855,7 +854,7 @@ void TLSWrap::ClearOut() {
855854Debug (this , " Trying to read cleartext output" );
856855
857856// No reads after EOF
858- if (eof_ ) {
857+ if (flags_. eof ) {
859858Debug (this , " Returning from ClearOut(), EOF reached" );
860859return ;
861860 }
@@ -911,8 +910,8 @@ void TLSWrap::ClearOut() {
911910int err = SSL_get_error (ssl_.get (), read);
912911switch (err) {
913912case SSL_ERROR_ZERO_RETURN :
914- if (!eof_ ) {
915- eof_ = true ;
913+ if (!flags_. eof ) {
914+ flags_. eof = true ;
916915EmitRead (UV_EOF );
917916 }
918917return ;
@@ -1005,7 +1004,7 @@ void TLSWrap::ClearIn() {
10051004int err = SSL_get_error (ssl_.get (), written);
10061005if (err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL ) {
10071006Debug (this , " Got SSL error (%d)" , err);
1008- write_callback_scheduled_ = true ;
1007+ flags_. write_callback_scheduled = true ;
10091008// TODO(@sam-github) Should forward an error object with
10101009// .code/.function/.etc, if possible.
10111010InvokeQueued (UV_EPROTO , GetBIOError ().c_str ());
@@ -1049,7 +1048,7 @@ bool TLSWrap::IsClosing() {
10491048
10501049int TLSWrap::ReadStart () {
10511050Debug (this , " ReadStart()" );
1052- if (underlying_stream () != nullptr && !eof_ )
1051+ if (underlying_stream () != nullptr && !flags_. eof )
10531052return underlying_stream ()->ReadStart ();
10541053return 0 ;
10551054}
@@ -1197,9 +1196,9 @@ int TLSWrap::DoWrite(WriteWrap* w,
11971196
11981197// Write any encrypted/handshake output that may be ready.
11991198// Guard against sync call of current_write_->Done(), its unsupported.
1200- in_dowrite_ = true ;
1199+ flags_. in_dowrite = true ;
12011200EncOut ();
1202- in_dowrite_ = false ;
1201+ flags_. in_dowrite = false ;
12031202
12041203return 0 ;
12051204}
@@ -1216,16 +1215,15 @@ void TLSWrap::OnStreamRead(ssize_t nread, const uv_buf_t& buf) {
12161215Debug (this , " Read %zd bytes from underlying stream" , nread);
12171216
12181217// Ignore everything after close_notify (rfc5246#section-7.2.1)
1219- if (eof_)
1220- return ;
1218+ if (flags_.eof ) return ;
12211219
12221220if (nread < 0 ) {
12231221// Error should be emitted only after all data was read
12241222ClearOut ();
12251223
12261224if (nread == UV_EOF ) {
12271225// underlying stream already should have also called ReadStop on itself
1228- eof_ = true ;
1226+ flags_. eof = true ;
12291227 }
12301228
12311229EmitRead (nread);
@@ -1256,7 +1254,7 @@ int TLSWrap::DoShutdown(ShutdownWrap* req_wrap) {
12561254if (ssl_ && SSL_shutdown (ssl_.get ()) == 0 )
12571255SSL_shutdown (ssl_.get ());
12581256
1259- shutdown_ = true ;
1257+ flags_. shutdown = true ;
12601258EncOut ();
12611259return underlying_stream ()->DoShutdown (req_wrap);
12621260}
@@ -1352,7 +1350,7 @@ void TLSWrap::Destroy() {
13521350return ;
13531351
13541352// If there is a write happening, mark it as finished.
1355- write_callback_scheduled_ = true ;
1353+ flags_. write_callback_scheduled = true ;
13561354
13571355// And destroy
13581356InvokeQueued (UV_ECANCELED , " Canceled because of SSL destruction" );
@@ -1389,7 +1387,7 @@ void TLSWrap::ResumeAfterCertCb(void* arg) {
13891387void TLSWrap::EnableALPNCb (const FunctionCallbackInfo<Value>& args) {
13901388 TLSWrap* wrap;
13911389ASSIGN_OR_RETURN_UNWRAP (&wrap, args.This ());
1392- wrap->alpn_callback_enabled_ = true ;
1390+ wrap->flags_ . alpn_callback_enabled = true ;
13931391
13941392SSL * ssl = wrap->ssl_ .get ();
13951393SSL_CTX * ssl_ctx = SSL_get_SSL_CTX (ssl);
@@ -1418,7 +1416,7 @@ void TLSWrap::SetServername(const FunctionCallbackInfo<Value>& args) {
14181416
14191417CHECK_EQ (args.Length (), 1 );
14201418CHECK (args[0 ]->IsString ());
1421- CHECK (!wrap->started_ );
1419+ CHECK (!wrap->flags_ . started );
14221420CHECK (wrap->is_client ());
14231421
14241422CHECK (wrap->ssl_ );
@@ -1633,7 +1631,7 @@ void TLSWrap::CertCbDone(const FunctionCallbackInfo<Value>& args) {
16331631 TLSWrap* w;
16341632ASSIGN_OR_RETURN_UNWRAP (&w, args.This ());
16351633
1636- CHECK (w->is_waiting_cert_cb () && w->cert_cb_running_ );
1634+ CHECK (w->is_waiting_cert_cb () && w->flags_ . cert_cb_running );
16371635
16381636 Local<Object> object = w->object ();
16391637 Local<Value> ctx = object->Get (env->context (), env->sni_context_string ())
@@ -1685,7 +1683,7 @@ void TLSWrap::CertCbDone(const FunctionCallbackInfo<Value>& args) {
16851683 cb = w->cert_cb_ ;
16861684 arg = w->cert_cb_arg_ ;
16871685
1688- w->cert_cb_running_ = false ;
1686+ w->flags_ . cert_cb_running = false ;
16891687 w->cert_cb_ = nullptr ;
16901688 w->cert_cb_arg_ = nullptr ;
16911689
@@ -2072,7 +2070,7 @@ void TLSWrap::ExportKeyingMaterial(const FunctionCallbackInfo<Value>& args) {
20722070void TLSWrap::ClientHelloDone (const FunctionCallbackInfo<Value>& args) {
20732071 TLSWrap* w;
20742072ASSIGN_OR_RETURN_UNWRAP (&w, args.This ());
2075- w->hello_answered_ = true ;
2073+ w->flags_ . hello_answered = true ;
20762074 w->Cycle ();
20772075}
20782076
@@ -2107,7 +2105,7 @@ void TLSWrap::GetTLSTicket(const FunctionCallbackInfo<Value>& args) {
21072105void TLSWrap::NewSessionDone (const FunctionCallbackInfo<Value>& args) {
21082106 TLSWrap* w;
21092107ASSIGN_OR_RETURN_UNWRAP (&w, args.This ());
2110- w->awaiting_new_session_ = false ;
2108+ w->flags_ . awaiting_new_session = false ;
21112109 w->NewSessionDoneCb ();
21122110}
21132111
@@ -2188,7 +2186,7 @@ void TLSWrap::WritesIssuedByPrevListenerDone(
21882186ASSIGN_OR_RETURN_UNWRAP (&w, args.This ());
21892187
21902188Debug (w, " WritesIssuedByPrevListenerDone is called" );
2191- w->has_active_write_issued_by_prev_listener_ = false ;
2189+ w->flags_ . has_active_write_issued_by_prev_listener = false ;
21922190 w->EncOut (); // resume all of our restrained writes
21932191}
21942192
0 commit comments