@@ -40,7 +40,7 @@ inline int Nghttp2Session::OnNghttpError(nghttp2_session* session,
40
40
void * user_data) {
41
41
Nghttp2Session* handle = static_cast <Nghttp2Session*>(user_data);
42
42
DEBUG_HTTP2 (" Nghttp2Session %s: Error '%.*s'\n " ,
43
- SESSION_TYPE_NAME ( handle), len, message);
43
+ handle-> TypeName ( ), len, message);
44
44
return 0 ;
45
45
}
46
46
#endif
@@ -56,7 +56,7 @@ inline int Nghttp2Session::OnBeginHeadersCallback(nghttp2_session* session,
56
56
frame->push_promise .promised_stream_id :
57
57
frame->hd .stream_id ;
58
58
DEBUG_HTTP2 (" Nghttp2Session %s: beginning headers for stream %d\n " ,
59
- SESSION_TYPE_NAME ( handle), id);
59
+ handle-> TypeName ( ), id);
60
60
61
61
Nghttp2Stream* stream = handle->FindStream (id);
62
62
if (stream == nullptr ) {
@@ -99,7 +99,7 @@ inline int Nghttp2Session::OnFrameReceive(nghttp2_session* session,
99
99
void * user_data) {
100
100
Nghttp2Session* handle = static_cast <Nghttp2Session*>(user_data);
101
101
DEBUG_HTTP2 (" Nghttp2Session %s: complete frame received: type: %d\n " ,
102
- SESSION_TYPE_NAME ( handle), frame->hd .type );
102
+ handle-> TypeName ( ), frame->hd .type );
103
103
bool ack;
104
104
switch (frame->hd .type ) {
105
105
case NGHTTP2_DATA:
@@ -131,7 +131,7 @@ inline int Nghttp2Session::OnFrameNotSent(nghttp2_session *session,
131
131
void *user_data) {
132
132
Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
133
133
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);
135
135
// Do not report if the frame was not sent due to the session closing
136
136
if (error_code != NGHTTP2_ERR_SESSION_CLOSING &&
137
137
error_code != NGHTTP2_ERR_STREAM_CLOSED &&
@@ -148,7 +148,7 @@ inline int Nghttp2Session::OnStreamClose(nghttp2_session *session,
148
148
void *user_data) {
149
149
Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
150
150
DEBUG_HTTP2 (" Nghttp2Session %s: stream %d closed, code: %d\n " ,
151
- SESSION_TYPE_NAME ( handle), id, code);
151
+ handle-> TypeName ( ), id, code);
152
152
Nghttp2Stream *stream = handle->FindStream (id);
153
153
// Intentionally ignore the callback if the stream does not exist
154
154
if (stream != nullptr )
@@ -168,7 +168,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session,
168
168
void *user_data) {
169
169
Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
170
170
DEBUG_HTTP2 (" Nghttp2Session %s: reading outbound file data for stream %d\n " ,
171
- SESSION_TYPE_NAME ( handle), id);
171
+ handle-> TypeName ( ), id);
172
172
Nghttp2Stream *stream = handle->FindStream (id);
173
173
174
174
int fd = source->fd ;
@@ -204,7 +204,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session,
204
204
// if numchars < length, assume that we are done.
205
205
if (static_cast <size_t >(numchars) < length || length <= 0 ) {
206
206
DEBUG_HTTP2 (" Nghttp2Session %s: no more data for stream %d\n " ,
207
- SESSION_TYPE_NAME ( handle), id);
207
+ handle-> TypeName ( ), id);
208
208
*flags |= NGHTTP2_DATA_FLAG_EOF;
209
209
GetTrailers (session, handle, stream, flags);
210
210
}
@@ -224,7 +224,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
224
224
void *user_data) {
225
225
Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
226
226
DEBUG_HTTP2 (" Nghttp2Session %s: reading outbound data for stream %d\n " ,
227
- SESSION_TYPE_NAME ( handle), id);
227
+ handle-> TypeName ( ), id);
228
228
Nghttp2Stream *stream = handle->FindStream (id);
229
229
size_t remaining = length;
230
230
size_t offset = 0 ;
@@ -234,7 +234,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
234
234
// calls this callback.
235
235
while (stream->queue_head_ != nullptr ) {
236
236
DEBUG_HTTP2 (" Nghttp2Session %s: processing outbound data chunk\n " ,
237
- SESSION_TYPE_NAME ( handle));
237
+ handle-> TypeName ( ));
238
238
nghttp2_stream_write_queue *head = stream->queue_head_ ;
239
239
while (stream->queue_head_index_ < head->nbufs ) {
240
240
if (remaining == 0 )
@@ -275,12 +275,12 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session,
275
275
int writable = stream->queue_head_ != nullptr || stream->IsWritable ();
276
276
if (offset == 0 && writable && stream->queue_head_ == nullptr ) {
277
277
DEBUG_HTTP2 (" Nghttp2Session %s: deferring stream %d\n " ,
278
- SESSION_TYPE_NAME ( handle), id);
278
+ handle-> TypeName ( ), id);
279
279
return NGHTTP2_ERR_DEFERRED;
280
280
}
281
281
if (!writable) {
282
282
DEBUG_HTTP2 (" Nghttp2Session %s: no more data for stream %d\n " ,
283
- SESSION_TYPE_NAME ( handle), id);
283
+ handle-> TypeName ( ), id);
284
284
*flags |= NGHTTP2_DATA_FLAG_EOF;
285
285
286
286
GetTrailers (session, handle, stream, flags);
@@ -299,7 +299,7 @@ inline ssize_t Nghttp2Session::OnSelectPadding(nghttp2_session *session,
299
299
assert (handle->HasGetPaddingCallback ());
300
300
ssize_t padding = handle->GetPadding (frame->hd .length , maxPayloadLen);
301
301
DEBUG_HTTP2 (" Nghttp2Session %s: using padding, size: %d\n " ,
302
- SESSION_TYPE_NAME ( handle), padding);
302
+ handle-> TypeName ( ), padding);
303
303
return padding;
304
304
}
305
305
@@ -312,7 +312,7 @@ inline int Nghttp2Session::OnDataChunkReceived(nghttp2_session *session,
312
312
void *user_data) {
313
313
Nghttp2Session *handle = static_cast <Nghttp2Session *>(user_data);
314
314
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);
316
316
Nghttp2Stream *stream = handle->FindStream (id);
317
317
nghttp2_data_chunk_t *chunk = data_chunk_free_list.pop ();
318
318
chunk->buf = uv_buf_init (new char [len], len);
@@ -346,7 +346,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers,
346
346
if (length == 0 )
347
347
return ;
348
348
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);
350
350
*flags_ |= NGHTTP2_DATA_FLAG_NO_END_STREAM;
351
351
nghttp2_submit_trailer (handle_->session_ ,
352
352
stream_->id (),
@@ -356,8 +356,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers,
356
356
357
357
// See: https://nghttp2.org/documentation/nghttp2_submit_shutdown_notice.html
358
358
inline 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 ());
361
360
nghttp2_submit_shutdown_notice (session_);
362
361
}
363
362
@@ -367,7 +366,7 @@ inline void Nghttp2Session::SubmitShutdownNotice() {
367
366
inline int Nghttp2Session::SubmitSettings (const nghttp2_settings_entry iv[],
368
367
size_t niv) {
369
368
DEBUG_HTTP2 (" Nghttp2Session %s: submitting settings, count: %d\n " ,
370
- SESSION_TYPE_NAME ( this ), niv);
369
+ TypeName ( ), niv);
371
370
return nghttp2_submit_settings (session_, NGHTTP2_FLAG_NONE, iv, niv);
372
371
}
373
372
@@ -376,11 +375,11 @@ inline Nghttp2Stream* Nghttp2Session::FindStream(int32_t id) {
376
375
auto s = streams_.find (id);
377
376
if (s != streams_.end ()) {
378
377
DEBUG_HTTP2 (" Nghttp2Session %s: stream %d found\n " ,
379
- SESSION_TYPE_NAME ( this ), id);
378
+ TypeName ( ), id);
380
379
return s->second ;
381
380
} else {
382
381
DEBUG_HTTP2 (" Nghttp2Session %s: stream %d not found\n " ,
383
- SESSION_TYPE_NAME ( this ), id);
382
+ TypeName ( ), id);
384
383
return nullptr ;
385
384
}
386
385
}
@@ -405,7 +404,7 @@ inline void Nghttp2Stream::FlushDataChunks(bool done) {
405
404
inline void Nghttp2Session::HandleDataFrame (const nghttp2_frame* frame) {
406
405
int32_t id = frame->hd .stream_id ;
407
406
DEBUG_HTTP2 (" Nghttp2Session %s: handling data frame for stream %d\n " ,
408
- SESSION_TYPE_NAME ( this ), id);
407
+ TypeName ( ), id);
409
408
Nghttp2Stream* stream = this ->FindStream (id);
410
409
// If the stream does not exist, something really bad happened
411
410
CHECK_NE (stream, nullptr );
@@ -421,7 +420,7 @@ inline void Nghttp2Session::HandleHeadersFrame(const nghttp2_frame* frame) {
421
420
int32_t id = (frame->hd .type == NGHTTP2_PUSH_PROMISE) ?
422
421
frame->push_promise .promised_stream_id : frame->hd .stream_id ;
423
422
DEBUG_HTTP2 (" Nghttp2Session %s: handling headers frame for stream %d\n " ,
424
- SESSION_TYPE_NAME ( this ), id);
423
+ TypeName ( ), id);
425
424
Nghttp2Stream* stream = FindStream (id);
426
425
// If the stream does not exist, something really bad happened
427
426
CHECK_NE (stream, nullptr );
@@ -437,7 +436,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
437
436
nghttp2_priority priority_frame = frame->priority ;
438
437
int32_t id = frame->hd .stream_id ;
439
438
DEBUG_HTTP2 (" Nghttp2Session %s: handling priority frame for stream %d\n " ,
440
- SESSION_TYPE_NAME ( this ), id);
439
+ TypeName ( ), id);
441
440
// Ignore the priority frame if stream ID is <= 0
442
441
// This actually should never happen because nghttp2 should treat this as
443
442
// an error condition that terminates the session.
@@ -450,8 +449,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
450
449
// Notifies the JS layer that a GOAWAY frame has been received
451
450
inline void Nghttp2Session::HandleGoawayFrame (const nghttp2_frame* frame) {
452
451
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 ());
455
453
456
454
OnGoAway (goaway_frame.last_stream_id ,
457
455
goaway_frame.error_code ,
@@ -461,8 +459,7 @@ inline void Nghttp2Session::HandleGoawayFrame(const nghttp2_frame* frame) {
461
459
462
460
// Prompts nghttp2 to flush the queue of pending data frames
463
461
inline 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 ());
466
463
// Do not attempt to send data on the socket if the destroying flag has
467
464
// been set. That means everything is shutting down and the socket
468
465
// will not be usable.
@@ -551,8 +548,7 @@ inline void Nghttp2Session::MarkDestroying() {
551
548
552
549
inline int Nghttp2Session::Free () {
553
550
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 ());
556
552
// Stop the loop
557
553
uv_prepare_stop (&prep_);
558
554
auto PrepClose = [](uv_handle_t * handle) {
@@ -566,8 +562,7 @@ inline int Nghttp2Session::Free() {
566
562
nghttp2_session_del (session_);
567
563
session_ = nullptr ;
568
564
loop_ = nullptr ;
569
- DEBUG_HTTP2 (" Nghttp2Session %s: session freed\n " ,
570
- SESSION_TYPE_NAME (this ));
565
+ DEBUG_HTTP2 (" Nghttp2Session %s: session freed\n " , TypeName ());
571
566
return 1 ;
572
567
}
573
568
0 commit comments