@@ -40,7 +40,7 @@ inline int Nghttp2Session::OnNghttpError(nghttp2_session* session,
4040 void * user_data) {
4141 Nghttp2Session* handle = static_cast <Nghttp2Session*>(user_data);
4242 DEBUG_HTTP2 (" Nghttp2Session %s: Error '%.*s'\n " ,
43- SESSION_TYPE_NAME ( handle), len, message);
43+ handle-> TypeName ( ), len, message);
4444 return 0 ;
4545}
4646#endif
@@ -56,7 +56,7 @@ inline int Nghttp2Session::OnBeginHeadersCallback(nghttp2_session* session,
5656 frame->push_promise .promised_stream_id :
5757 frame->hd .stream_id ;
5858 DEBUG_HTTP2 (" Nghttp2Session %s: beginning headers for stream %d\n " ,
59- SESSION_TYPE_NAME ( handle), id);
59+ handle-> TypeName ( ), id);
6060
6161 Nghttp2Stream* stream = handle->FindStream (id);
6262 if (stream == nullptr ) {
@@ -99,7 +99,7 @@ inline int Nghttp2Session::OnFrameReceive(nghttp2_session* session,
9999 void * user_data) {
100100 Nghttp2Session* handle = static_cast <Nghttp2Session*>(user_data);
101101 DEBUG_HTTP2 (" Nghttp2Session %s: complete frame received: type: %d\n " ,
102- SESSION_TYPE_NAME ( handle), frame->hd .type );
102+ handle-> TypeName ( ), frame->hd .type );
103103 bool ack;
104104 switch (frame->hd .type ) {
105105 case NGHTTP2_DATA:
@@ -131,7 +131,7 @@ inline int Nghttp2Session::OnFrameNotSent(nghttp2_session *session,
131131 void *user_data) {
132132 Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
133133 DEBUG_HTTP2 (" Nghttp2Session %s: frame type %d was not sent, code: %d\n " ,
134- SESSION_TYPE_NAME ( handle), frame->hd .type , error_code);
134+ handle-> TypeName ( ), frame->hd .type , error_code);
135135 // Do not report if the frame was not sent due to the session closing
136136 if (error_code != NGHTTP2_ERR_SESSION_CLOSING &&
137137 error_code != NGHTTP2_ERR_STREAM_CLOSED &&
@@ -148,7 +148,7 @@ inline int Nghttp2Session::OnStreamClose(nghttp2_session *session,
148148 void *user_data) {
149149 Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
150150 DEBUG_HTTP2 (" Nghttp2Session %s: stream %d closed, code: %d\n " ,
151- SESSION_TYPE_NAME ( handle), id, code);
151+ handle-> TypeName ( ), id, code);
152152 Nghttp2Stream *stream = handle->FindStream (id);
153153 // Intentionally ignore the callback if the stream does not exist
154154 if (stream != nullptr )
@@ -168,7 +168,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session,
168168 void *user_data) {
169169 Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
170170 DEBUG_HTTP2 (" Nghttp2Session %s: reading outbound file data for stream %d\n " ,
171- SESSION_TYPE_NAME ( handle), id);
171+ handle-> TypeName ( ), id);
172172 Nghttp2Stream *stream = handle->FindStream (id);
173173
174174 int fd = source->fd ;
@@ -204,7 +204,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session,
204204 // if numchars < length, assume that we are done.
205205 if (static_cast <size_t >(numchars) < length || length <= 0 ) {
206206 DEBUG_HTTP2 (" Nghttp2Session %s: no more data for stream %d\n " ,
207- SESSION_TYPE_NAME ( handle), id);
207+ handle-> TypeName ( ), id);
208208 *flags |= NGHTTP2_DATA_FLAG_EOF;
209209 GetTrailers (session, handle, stream, flags);
210210 }
@@ -224,7 +224,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
224224 void *user_data) {
225225 Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
226226 DEBUG_HTTP2 (" Nghttp2Session %s: reading outbound data for stream %d\n " ,
227- SESSION_TYPE_NAME ( handle), id);
227+ handle-> TypeName ( ), id);
228228 Nghttp2Stream *stream = handle->FindStream (id);
229229 size_t remaining = length;
230230 size_t offset = 0 ;
@@ -234,7 +234,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
234234 // calls this callback.
235235 while (stream->queue_head_ != nullptr ) {
236236 DEBUG_HTTP2 (" Nghttp2Session %s: processing outbound data chunk\n " ,
237- SESSION_TYPE_NAME ( handle));
237+ handle-> TypeName ( ));
238238 nghttp2_stream_write_queue *head = stream->queue_head_ ;
239239 while (stream->queue_head_index_ < head->nbufs ) {
240240 if (remaining == 0 )
@@ -275,12 +275,12 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
275275 int writable = stream->queue_head_ != nullptr || stream->IsWritable ();
276276 if (offset == 0 && writable && stream->queue_head_ == nullptr ) {
277277 DEBUG_HTTP2 (" Nghttp2Session %s: deferring stream %d\n " ,
278- SESSION_TYPE_NAME ( handle), id);
278+ handle-> TypeName ( ), id);
279279 return NGHTTP2_ERR_DEFERRED;
280280 }
281281 if (!writable) {
282282 DEBUG_HTTP2 (" Nghttp2Session %s: no more data for stream %d\n " ,
283- SESSION_TYPE_NAME ( handle), id);
283+ handle-> TypeName ( ), id);
284284 *flags |= NGHTTP2_DATA_FLAG_EOF;
285285
286286 GetTrailers (session, handle, stream, flags);
@@ -299,7 +299,7 @@ inline ssize_t Nghttp2Session::OnSelectPadding(nghttp2_session *session,
299299 assert (handle->HasGetPaddingCallback ());
300300 ssize_t padding = handle->GetPadding (frame->hd .length , maxPayloadLen);
301301 DEBUG_HTTP2 (" Nghttp2Session %s: using padding, size: %d\n " ,
302- SESSION_TYPE_NAME ( handle), padding);
302+ handle-> TypeName ( ), padding);
303303 return padding;
304304}
305305
@@ -312,7 +312,7 @@ inline int Nghttp2Session::OnDataChunkReceived(nghttp2_session *session,
312312 void *user_data) {
313313 Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
314314 DEBUG_HTTP2 (" Nghttp2Session %s: buffering data chunk for stream %d, size: "
315- " %d, flags: %d\n " , SESSION_TYPE_NAME ( handle), id, len, flags);
315+ " %d, flags: %d\n " , handle-> TypeName ( ), id, len, flags);
316316 Nghttp2Stream *stream = handle->FindStream (id);
317317 nghttp2_data_chunk_t *chunk = data_chunk_free_list.pop ();
318318 chunk->buf = uv_buf_init (new char [len], len);
@@ -346,7 +346,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers,
346346 if (length == 0 )
347347 return ;
348348 DEBUG_HTTP2 (" Nghttp2Session %s: sending trailers for stream %d, "
349- " count: %d\n " , SESSION_TYPE_NAME ( handle_), stream_->id (), length);
349+ " count: %d\n " , handle_-> TypeName ( ), stream_->id (), length);
350350 *flags_ |= NGHTTP2_DATA_FLAG_NO_END_STREAM;
351351 nghttp2_submit_trailer (handle_->session_ ,
352352 stream_->id (),
@@ -356,8 +356,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers,
356356
357357// See: https://nghttp2.org/documentation/nghttp2_submit_shutdown_notice.html
358358inline void Nghttp2Session::SubmitShutdownNotice () {
359- DEBUG_HTTP2 (" Nghttp2Session %s: submitting shutdown notice\n " ,
360- SESSION_TYPE_NAME (this ));
359+ DEBUG_HTTP2 (" Nghttp2Session %s: submitting shutdown notice\n " , TypeName ());
361360 nghttp2_submit_shutdown_notice (session_);
362361}
363362
@@ -367,7 +366,7 @@ inline void Nghttp2Session::SubmitShutdownNotice() {
367366inline int Nghttp2Session::SubmitSettings (const nghttp2_settings_entry iv[],
368367 size_t niv) {
369368 DEBUG_HTTP2 (" Nghttp2Session %s: submitting settings, count: %d\n " ,
370- SESSION_TYPE_NAME ( this ), niv);
369+ TypeName ( ), niv);
371370 return nghttp2_submit_settings (session_, NGHTTP2_FLAG_NONE, iv, niv);
372371}
373372
@@ -376,11 +375,11 @@ inline Nghttp2Stream* Nghttp2Session::FindStream(int32_t id) {
376375 auto s = streams_.find (id);
377376 if (s != streams_.end ()) {
378377 DEBUG_HTTP2 (" Nghttp2Session %s: stream %d found\n " ,
379- SESSION_TYPE_NAME ( this ), id);
378+ TypeName ( ), id);
380379 return s->second ;
381380 } else {
382381 DEBUG_HTTP2 (" Nghttp2Session %s: stream %d not found\n " ,
383- SESSION_TYPE_NAME ( this ), id);
382+ TypeName ( ), id);
384383 return nullptr ;
385384 }
386385}
@@ -405,7 +404,7 @@ inline void Nghttp2Stream::FlushDataChunks(bool done) {
405404inline void Nghttp2Session::HandleDataFrame (const nghttp2_frame* frame) {
406405 int32_t id = frame->hd .stream_id ;
407406 DEBUG_HTTP2 (" Nghttp2Session %s: handling data frame for stream %d\n " ,
408- SESSION_TYPE_NAME ( this ), id);
407+ TypeName ( ), id);
409408 Nghttp2Stream* stream = this ->FindStream (id);
410409 // If the stream does not exist, something really bad happened
411410 CHECK_NE (stream, nullptr );
@@ -421,7 +420,7 @@ inline void Nghttp2Session::HandleHeadersFrame(const nghttp2_frame* frame) {
421420 int32_t id = (frame->hd .type == NGHTTP2_PUSH_PROMISE) ?
422421 frame->push_promise .promised_stream_id : frame->hd .stream_id ;
423422 DEBUG_HTTP2 (" Nghttp2Session %s: handling headers frame for stream %d\n " ,
424- SESSION_TYPE_NAME ( this ), id);
423+ TypeName ( ), id);
425424 Nghttp2Stream* stream = FindStream (id);
426425 // If the stream does not exist, something really bad happened
427426 CHECK_NE (stream, nullptr );
@@ -437,7 +436,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
437436 nghttp2_priority priority_frame = frame->priority ;
438437 int32_t id = frame->hd .stream_id ;
439438 DEBUG_HTTP2 (" Nghttp2Session %s: handling priority frame for stream %d\n " ,
440- SESSION_TYPE_NAME ( this ), id);
439+ TypeName ( ), id);
441440 // Ignore the priority frame if stream ID is <= 0
442441 // This actually should never happen because nghttp2 should treat this as
443442 // an error condition that terminates the session.
@@ -450,8 +449,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
450449// Notifies the JS layer that a GOAWAY frame has been received
451450inline void Nghttp2Session::HandleGoawayFrame (const nghttp2_frame* frame) {
452451 nghttp2_goaway goaway_frame = frame->goaway ;
453- DEBUG_HTTP2 (" Nghttp2Session %s: handling goaway frame\n " ,
454- SESSION_TYPE_NAME (this ));
452+ DEBUG_HTTP2 (" Nghttp2Session %s: handling goaway frame\n " , TypeName ());
455453
456454 OnGoAway (goaway_frame.last_stream_id ,
457455 goaway_frame.error_code ,
@@ -461,8 +459,7 @@ inline void Nghttp2Session::HandleGoawayFrame(const nghttp2_frame* frame) {
461459
462460// Prompts nghttp2 to flush the queue of pending data frames
463461inline void Nghttp2Session::SendPendingData () {
464- DEBUG_HTTP2 (" Nghttp2Session %s: Sending pending data\n " ,
465- SESSION_TYPE_NAME (this ));
462+ DEBUG_HTTP2 (" Nghttp2Session %s: Sending pending data\n " , TypeName ());
466463 // Do not attempt to send data on the socket if the destroying flag has
467464 // been set. That means everything is shutting down and the socket
468465 // will not be usable.
@@ -551,8 +548,7 @@ inline void Nghttp2Session::MarkDestroying() {
551548
552549inline int Nghttp2Session::Free () {
553550 assert (session_ != nullptr );
554- DEBUG_HTTP2 (" Nghttp2Session %s: freeing session\n " ,
555- SESSION_TYPE_NAME (this ));
551+ DEBUG_HTTP2 (" Nghttp2Session %s: freeing session\n " , TypeName ());
556552 // Stop the loop
557553 uv_prepare_stop (&prep_);
558554 auto PrepClose = [](uv_handle_t * handle) {
@@ -566,8 +562,7 @@ inline int Nghttp2Session::Free() {
566562 nghttp2_session_del (session_);
567563 session_ = nullptr ;
568564 loop_ = nullptr ;
569- DEBUG_HTTP2 (" Nghttp2Session %s: session freed\n " ,
570- SESSION_TYPE_NAME (this ));
565+ DEBUG_HTTP2 (" Nghttp2Session %s: session freed\n " , TypeName ());
571566 return 1 ;
572567}
573568
0 commit comments