| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | - handle->TypeName(handle->type()), len, message); | ||
| 43 | + handle->TypeName(), len, message); | ||
| 44 | 44 | return 0; | |
| 45 | 45 | } | |
| 46 | 46 | #endif | |
@@ -58,7 +58,7 @@ inline int Nghttp2Session::OnBeginHeadersCallback(nghttp2_session* session, | |||
| 58 | 58 | frame->push_promise.promised_stream_id : | |
| 59 | 59 | frame->hd.stream_id; | |
| 60 | 60 | DEBUG_HTTP2("Nghttp2Session %s: beginning headers for stream %d\n", | |
| 61 | - handle->TypeName(handle->type()), id); | ||
| 61 | + handle->TypeName(), id); | ||
| 62 | 62 | ||
| 63 | 63 | Nghttp2Stream* stream = handle->FindStream(id); | |
| 64 | 64 | if (stream == nullptr) { | |
@@ -103,7 +103,7 @@ inline int Nghttp2Session::OnFrameReceive(nghttp2_session* session, | |||
| 103 | 103 | void* user_data) { | |
| 104 | 104 | Nghttp2Session* handle = static_cast<Nghttp2Session*>(user_data); | |
| 105 | 105 | DEBUG_HTTP2("Nghttp2Session %s: complete frame received: type: %d\n", | |
| 106 | - handle->TypeName(handle->type()), frame->hd.type); | ||
| 106 | + handle->TypeName(), frame->hd.type); | ||
| 107 | 107 | bool ack; | |
| 108 | 108 | switch (frame->hd.type) { | |
| 109 | 109 | case NGHTTP2_DATA: | |
@@ -135,7 +135,7 @@ inline int Nghttp2Session::OnFrameNotSent(nghttp2_session *session, | |||
| 135 | 135 | void *user_data) { | |
| 136 | 136 | Nghttp2Session *handle = static_cast<Nghttp2Session *>(user_data); | |
| 137 | 137 | DEBUG_HTTP2("Nghttp2Session %s: frame type %d was not sent, code: %d\n", | |
| 138 | - handle->TypeName(handle->type()), frame->hd.type, error_code); | ||
| 138 | + handle->TypeName(), frame->hd.type, error_code); | ||
| 139 | 139 | // Do not report if the frame was not sent due to the session closing | |
| 140 | 140 | if (error_code != NGHTTP2_ERR_SESSION_CLOSING && | |
| 141 | 141 | error_code != NGHTTP2_ERR_STREAM_CLOSED && | |
@@ -162,7 +162,7 @@ inline int Nghttp2Session::OnStreamClose(nghttp2_session *session, | |||
| 162 | 162 | void *user_data) { | |
| 163 | 163 | Nghttp2Session *handle = static_cast<Nghttp2Session *>(user_data); | |
| 164 | 164 | DEBUG_HTTP2("Nghttp2Session %s: stream %d closed, code: %d\n", | |
| 165 | - handle->TypeName(handle->type()), id, code); | ||
| 165 | + handle->TypeName(), id, code); | ||
| 166 | 166 | Nghttp2Stream *stream = handle->FindStream(id); | |
| 167 | 167 | // Intentionally ignore the callback if the stream does not exist | |
| 168 | 168 | if (stream != nullptr) | |
@@ -182,7 +182,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session, | |||
| 182 | 182 | void *user_data) { | |
| 183 | 183 | Nghttp2Session *handle = static_cast<Nghttp2Session *>(user_data); | |
| 184 | 184 | DEBUG_HTTP2("Nghttp2Session %s: reading outbound file data for stream %d\n", | |
| 185 | - handle->TypeName(handle->type()), id); | ||
| 185 | + handle->TypeName(), id); | ||
| 186 | 186 | Nghttp2Stream *stream = handle->FindStream(id); | |
| 187 | 187 | ||
| 188 | 188 | int fd = source->fd; | |
@@ -218,7 +218,7 @@ inline ssize_t Nghttp2Session::OnStreamReadFD(nghttp2_session *session, | |||
| 218 | 218 | // if numchars < length, assume that we are done. | |
| 219 | 219 | if (static_cast<size_t>(numchars) < length || length <= 0) { | |
| 220 | 220 | DEBUG_HTTP2("Nghttp2Session %s: no more data for stream %d\n", | |
| 221 | - handle->TypeName(handle->type()), id); | ||
| 221 | + handle->TypeName(), id); | ||
| 222 | 222 | *flags |= NGHTTP2_DATA_FLAG_EOF; | |
| 223 | 223 | GetTrailers(session, handle, stream, flags); | |
| 224 | 224 | } | |
@@ -238,7 +238,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session, | |||
| 238 | 238 | void *user_data) { | |
| 239 | 239 | Nghttp2Session *handle = static_cast<Nghttp2Session *>(user_data); | |
| 240 | 240 | DEBUG_HTTP2("Nghttp2Session %s: reading outbound data for stream %d\n", | |
| 241 | - handle->TypeName(handle->type()), id); | ||
| 241 | + handle->TypeName(), id); | ||
| 242 | 242 | Nghttp2Stream *stream = handle->FindStream(id); | |
| 243 | 243 | size_t remaining = length; | |
| 244 | 244 | size_t offset = 0; | |
@@ -248,7 +248,7 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session, | |||
| 248 | 248 | // calls this callback. | |
| 249 | 249 | while (stream->queue_head_ != nullptr) { | |
| 250 | 250 | DEBUG_HTTP2("Nghttp2Session %s: processing outbound data chunk\n", | |
| 251 | - handle->TypeName(handle->type())); | ||
| 251 | + handle->TypeName()); | ||
| 252 | 252 | nghttp2_stream_write_queue *head = stream->queue_head_; | |
| 253 | 253 | while (stream->queue_head_index_ < head->nbufs) { | |
| 254 | 254 | if (remaining == 0) | |
@@ -289,12 +289,12 @@ inline ssize_t Nghttp2Session::OnStreamRead(nghttp2_session *session, | |||
| 289 | 289 | int writable = stream->queue_head_ != nullptr || stream->IsWritable(); | |
| 290 | 290 | if (offset == 0 && writable && stream->queue_head_ == nullptr) { | |
| 291 | 291 | DEBUG_HTTP2("Nghttp2Session %s: deferring stream %d\n", | |
| 292 | - handle->TypeName(handle->type()), id); | ||
| 292 | + handle->TypeName(), id); | ||
| 293 | 293 | return NGHTTP2_ERR_DEFERRED; | |
| 294 | 294 | } | |
| 295 | 295 | if (!writable) { | |
| 296 | 296 | DEBUG_HTTP2("Nghttp2Session %s: no more data for stream %d\n", | |
| 297 | - handle->TypeName(handle->type()), id); | ||
| 297 | + handle->TypeName(), id); | ||
| 298 | 298 | *flags |= NGHTTP2_DATA_FLAG_EOF; | |
| 299 | 299 | ||
| 300 | 300 | GetTrailers(session, handle, stream, flags); | |
@@ -313,7 +313,7 @@ inline ssize_t Nghttp2Session::OnSelectPadding(nghttp2_session *session, | |||
| 313 | 313 | CHECK(handle->HasGetPaddingCallback()); | |
| 314 | 314 | ssize_t padding = handle->GetPadding(frame->hd.length, maxPayloadLen); | |
| 315 | 315 | DEBUG_HTTP2("Nghttp2Session %s: using padding, size: %d\n", | |
| 316 | - handle->TypeName(handle->type()), padding); | ||
| 316 | + handle->TypeName(), padding); | ||
| 317 | 317 | return padding; | |
| 318 | 318 | } | |
| 319 | 319 | ||
@@ -326,7 +326,7 @@ inline int Nghttp2Session::OnDataChunkReceived(nghttp2_session *session, | |||
| 326 | 326 | void *user_data) { | |
| 327 | 327 | Nghttp2Session *handle = static_cast<Nghttp2Session *>(user_data); | |
| 328 | 328 | DEBUG_HTTP2("Nghttp2Session %s: buffering data chunk for stream %d, size: " | |
| 329 | - "%d, flags: %d\n", handle->TypeName(handle->type()), | ||
| 329 | + "%d, flags: %d\n", handle->TypeName(), | ||
| 330 | 330 | id, len, flags); | |
| 331 | 331 | Nghttp2Stream *stream = handle->FindStream(id); | |
| 332 | 332 | nghttp2_data_chunk_t *chunk = data_chunk_free_list.pop(); | |
@@ -361,7 +361,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers, | |||
| 361 | 361 | if (length == 0) | |
| 362 | 362 | return; | |
| 363 | 363 | DEBUG_HTTP2("Nghttp2Session %s: sending trailers for stream %d, " | |
| 364 | - "count: %d\n", handle_->TypeName(handle_->type()), | ||
| 364 | + "count: %d\n", handle_->TypeName(), | ||
| 365 | 365 | stream_->id(), length); | |
| 366 | 366 | *flags_ |= NGHTTP2_DATA_FLAG_NO_END_STREAM; | |
| 367 | 367 | nghttp2_submit_trailer(handle_->session_, | |
@@ -373,7 +373,7 @@ inline void Nghttp2Session::SubmitTrailers::Submit(nghttp2_nv *trailers, | |||
| 373 | 373 | // See: https://nghttp2.org/documentation/nghttp2_submit_shutdown_notice.html | |
| 374 | 374 | inline void Nghttp2Session::SubmitShutdownNotice() { | |
| 375 | 375 | DEBUG_HTTP2("Nghttp2Session %s: submitting shutdown notice\n", | |
| 376 | - TypeName(type())); | ||
| 376 | + TypeName()); | ||
| 377 | 377 | nghttp2_submit_shutdown_notice(session_); | |
| 378 | 378 | } | |
| 379 | 379 | ||
@@ -383,7 +383,7 @@ inline void Nghttp2Session::SubmitShutdownNotice() { | |||
| 383 | 383 | inline int Nghttp2Session::SubmitSettings(const nghttp2_settings_entry iv[], | |
| 384 | 384 | size_t niv) { | |
| 385 | 385 | DEBUG_HTTP2("Nghttp2Session %s: submitting settings, count: %d\n", | |
| 386 | - TypeName(type()), niv); | ||
| 386 | + TypeName(), niv); | ||
| 387 | 387 | return nghttp2_submit_settings(session_, NGHTTP2_FLAG_NONE, iv, niv); | |
| 388 | 388 | } | |
| 389 | 389 | ||
@@ -392,11 +392,10 @@ inline Nghttp2Stream* Nghttp2Session::FindStream(int32_t id) { | |||
| 392 | 392 | auto s = streams_.find(id); | |
| 393 | 393 | if (s != streams_.end()) { | |
| 394 | 394 | DEBUG_HTTP2("Nghttp2Session %s: stream %d found\n", | |
| 395 | - TypeName(type()), id); | ||
| 395 | + TypeName(), id); | ||
| 396 | 396 | return s->second; | |
| 397 | 397 | } else { | |
| 398 | - DEBUG_HTTP2("Nghttp2Session %s: stream %d not found\n", | ||
| 399 | - TypeName(type()), id); | ||
| 398 | + DEBUG_HTTP2("Nghttp2Session %s: stream %d not found\n", TypeName(), id); | ||
| 400 | 399 | return nullptr; | |
| 401 | 400 | } | |
| 402 | 401 | } | |
@@ -421,7 +420,7 @@ inline void Nghttp2Stream::FlushDataChunks(bool done) { | |||
| 421 | 420 | inline void Nghttp2Session::HandleDataFrame(const nghttp2_frame* frame) { | |
| 422 | 421 | int32_t id = frame->hd.stream_id; | |
| 423 | 422 | DEBUG_HTTP2("Nghttp2Session %s: handling data frame for stream %d\n", | |
| 424 | - TypeName(type()), id); | ||
| 423 | + TypeName(), id); | ||
| 425 | 424 | Nghttp2Stream* stream = this->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::HandleHeadersFrame(const nghttp2_frame* frame) { | |||
| 437 | 436 | int32_t id = (frame->hd.type == NGHTTP2_PUSH_PROMISE) ? | |
| 438 | 437 | frame->push_promise.promised_stream_id : frame->hd.stream_id; | |
| 439 | 438 | DEBUG_HTTP2("Nghttp2Session %s: handling headers frame for stream %d\n", | |
| 440 | - TypeName(type()), id); | ||
| 439 | + TypeName(), id); | ||
| 441 | 440 | Nghttp2Stream* stream = FindStream(id); | |
| 442 | 441 | // If the stream does not exist, something really bad happened | |
| 443 | 442 | CHECK_NE(stream, nullptr); | |
@@ -453,7 +452,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) { | |||
| 453 | 452 | nghttp2_priority priority_frame = frame->priority; | |
| 454 | 453 | int32_t id = frame->hd.stream_id; | |
| 455 | 454 | DEBUG_HTTP2("Nghttp2Session %s: handling priority frame for stream %d\n", | |
| 456 | - TypeName(type()), id); | ||
| 455 | + TypeName(), id); | ||
| 457 | 456 | // Ignore the priority frame if stream ID is <= 0 | |
| 458 | 457 | // This actually should never happen because nghttp2 should treat this as | |
| 459 | 458 | // an error condition that terminates the session. | |
@@ -466,7 +465,7 @@ inline void Nghttp2Session::HandlePriorityFrame(const nghttp2_frame* frame) { | |||
| 466 | 465 | // Notifies the JS layer that a GOAWAY frame has been received | |
| 467 | 466 | inline void Nghttp2Session::HandleGoawayFrame(const nghttp2_frame* frame) { | |
| 468 | 467 | nghttp2_goaway goaway_frame = frame->goaway; | |
| 469 | - DEBUG_HTTP2("Nghttp2Session %s: handling goaway frame\n", TypeName(type())); | ||
| 468 | + DEBUG_HTTP2("Nghttp2Session %s: handling goaway frame\n", TypeName()); | ||
| 470 | 469 | ||
| 471 | 470 | OnGoAway(goaway_frame.last_stream_id, | |
| 472 | 471 | goaway_frame.error_code, | |
@@ -476,7 +475,7 @@ inline void Nghttp2Session::HandleGoawayFrame(const nghttp2_frame* frame) { | |||
| 476 | 475 | ||
| 477 | 476 | // Prompts nghttp2 to flush the queue of pending data frames | |
| 478 | 477 | inline void Nghttp2Session::SendPendingData() { | |
| 479 | - DEBUG_HTTP2("Nghttp2Session %s: Sending pending data\n", TypeName(type())); | ||
| 478 | + DEBUG_HTTP2("Nghttp2Session %s: Sending pending data\n", TypeName()); | ||
| 480 | 479 | // Do not attempt to send data on the socket if the destroying flag has | |
| 481 | 480 | // been set. That means everything is shutting down and the socket | |
| 482 | 481 | // will not be usable. | |
@@ -510,10 +509,9 @@ inline int Nghttp2Session::Init(uv_loop_t* loop, | |||
| 510 | 509 | const nghttp2_session_type type, | |
| 511 | 510 | nghttp2_option* options, | |
| 512 | 511 | nghttp2_mem* mem) { | |
| 513 | - DEBUG_HTTP2("Nghttp2Session %s: initializing session\n", | ||
| 514 | - TypeName(type)); | ||
| 515 | 512 | loop_ = loop; | |
| 516 | 513 | session_type_ = type; | |
| 514 | + DEBUG_HTTP2("Nghttp2Session %s: initializing session\n", TypeName()); | ||
| 517 | 515 | destroying_ = false; | |
| 518 | 516 | int ret = 0; | |
| 519 | 517 | ||
@@ -565,7 +563,7 @@ inline void Nghttp2Session::MarkDestroying() { | |||
| 565 | 563 | ||
| 566 | 564 | inline int Nghttp2Session::Free() { | |
| 567 | 565 | CHECK(session_ != nullptr); | |
| 568 | - DEBUG_HTTP2("Nghttp2Session %s: freeing session\n", TypeName(type())); | ||
| 566 | + DEBUG_HTTP2("Nghttp2Session %s: freeing session\n", TypeName()); | ||
| 569 | 567 | // Stop the loop | |
| 570 | 568 | uv_prepare_stop(&prep_); | |
| 571 | 569 | auto PrepClose = [](uv_handle_t* handle) { | |
@@ -579,7 +577,7 @@ inline int Nghttp2Session::Free() { | |||
| 579 | 577 | nghttp2_session_del(session_); | |
| 580 | 578 | session_ = nullptr; | |
| 581 | 579 | loop_ = nullptr; | |
| 582 | - DEBUG_HTTP2("Nghttp2Session %s: session freed\n", TypeName(type())); | ||
| 580 | + DEBUG_HTTP2("Nghttp2Session %s: session freed\n", TypeName()); | ||
| 583 | 581 | return 1; | |
| 584 | 582 | } | |
| 585 | 583 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,8 +105,8 @@ class Nghttp2Session { | |||
| 105 | 105 | return destroying_; | |
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | - inline const char* TypeName(nghttp2_session_type type) { | ||
| 109 | - switch (type) { | ||
| 108 | + inline const char* TypeName() { | ||
| 109 | + switch (session_type_) { | ||
| 110 | 110 | case NGHTTP2_SESSION_SERVER: return "server"; | |
| 111 | 111 | case NGHTTP2_SESSION_CLIENT: return "client"; | |
| 112 | 112 | default: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments