| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -595,9 +595,8 @@ void Http2Session::Close(uint32_t code, bool socket_closed) { | |||
| 595 | 595 | Http2Scope h2scope(this); | |
| 596 | 596 | DEBUG_HTTP2SESSION2(this, "terminating session with code %d", code); | |
| 597 | 597 | CHECK_EQ(nghttp2_session_terminate_session(session_, code), 0); | |
| 598 | - } else { | ||
| 599 | - if (stream_ != nullptr) | ||
| 600 | - stream_->RemoveStreamListener(this); | ||
| 598 | + } else if (stream_ != nullptr) { | ||
| 599 | + stream_->RemoveStreamListener(this); | ||
| 601 | 600 | } | |
| 602 | 601 | ||
| 603 | 602 | // If there are outstanding pings, those will need to be canceled, do | |
@@ -688,10 +687,6 @@ ssize_t Http2Session::OnCallbackPadding(size_t frameLen, | |||
| 688 | 687 | Local<Context> context = env()->context(); | |
| 689 | 688 | Context::Scope context_scope(context); | |
| 690 | 689 | ||
| 691 | - #if defined(DEBUG) && DEBUG | ||
| 692 | - CHECK(object()->Has(context, env()->ongetpadding_string()).FromJust()); | ||
| 693 | - #endif | ||
| 694 | - | ||
| 695 | 690 | AliasedBuffer<uint32_t, v8::Uint32Array>& buffer = | |
| 696 | 691 | env()->http2_state()->padding_buffer; | |
| 697 | 692 | buffer[PADDING_BUF_FRAME_LENGTH] = frameLen; | |
@@ -760,18 +755,14 @@ int Http2Session::OnBeginHeadersCallback(nghttp2_session* handle, | |||
| 760 | 755 | ||
| 761 | 756 | Http2Stream* stream = session->FindStream(id); | |
| 762 | 757 | if (stream == nullptr) { | |
| 763 | - if (session->CanAddStream()) { | ||
| 764 | - new Http2Stream(session, id, frame->headers.cat); | ||
| 765 | - } else { | ||
| 758 | + if (!session->CanAddStream()) { | ||
| 766 | 759 | // Too many concurrent streams being opened | |
| 767 | 760 | nghttp2_submit_rst_stream(**session, NGHTTP2_FLAG_NONE, id, | |
| 768 | 761 | NGHTTP2_ENHANCE_YOUR_CALM); | |
| 769 | 762 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; | |
| 770 | 763 | } | |
| 771 | - } else { | ||
| 772 | - // If the stream has already been destroyed, ignore. | ||
| 773 | - if (stream->IsDestroyed()) | ||
| 774 | - return 0; | ||
| 764 | + new Http2Stream(session, id, frame->headers.cat); | ||
| 765 | + } else if (!stream->IsDestroyed()) { | ||
| 775 | 766 | stream->StartHeaders(frame->headers.cat); | |
| 776 | 767 | } | |
| 777 | 768 | return 0; | |
@@ -791,9 +782,7 @@ int Http2Session::OnHeaderCallback(nghttp2_session* handle, | |||
| 791 | 782 | Http2Stream* stream = session->FindStream(id); | |
| 792 | 783 | CHECK_NE(stream, nullptr); | |
| 793 | 784 | // If the stream has already been destroyed, ignore. | |
| 794 | - if (stream->IsDestroyed()) | ||
| 795 | - return 0; | ||
| 796 | - if (!stream->AddHeader(name, value, flags)) { | ||
| 785 | + if (!stream->IsDestroyed() && !stream->AddHeader(name, value, flags)) { | ||
| 797 | 786 | // This will only happen if the connected peer sends us more | |
| 798 | 787 | // than the allowed number of header items at any given time | |
| 799 | 788 | stream->SubmitRstStream(NGHTTP2_ENHANCE_YOUR_CALM); | |
@@ -859,11 +848,8 @@ int Http2Session::OnInvalidFrame(nghttp2_session* handle, | |||
| 859 | 848 | HandleScope scope(isolate); | |
| 860 | 849 | Local<Context> context = env->context(); | |
| 861 | 850 | Context::Scope context_scope(context); | |
| 862 | - | ||
| 863 | - Local<Value> argv[1] = { | ||
| 864 | - Integer::New(isolate, lib_error_code), | ||
| 865 | - }; | ||
| 866 | - session->MakeCallback(env->error_string(), arraysize(argv), argv); | ||
| 851 | + Local<Value> arg = Integer::New(isolate, lib_error_code); | ||
| 852 | + session->MakeCallback(env->error_string(), 1, &arg); | ||
| 867 | 853 | } | |
| 868 | 854 | return 0; | |
| 869 | 855 | } | |
@@ -1071,11 +1057,8 @@ int Http2Session::OnNghttpError(nghttp2_session* handle, | |||
| 1071 | 1057 | HandleScope scope(isolate); | |
| 1072 | 1058 | Local<Context> context = env->context(); | |
| 1073 | 1059 | Context::Scope context_scope(context); | |
| 1074 | - | ||
| 1075 | - Local<Value> argv[1] = { | ||
| 1076 | - Integer::New(isolate, NGHTTP2_ERR_PROTO), | ||
| 1077 | - }; | ||
| 1078 | - session->MakeCallback(env->error_string(), arraysize(argv), argv); | ||
| 1060 | + Local<Value> arg = Integer::New(isolate, NGHTTP2_ERR_PROTO); | ||
| 1061 | + session->MakeCallback(env->error_string(), 1, &arg); | ||
| 1079 | 1062 | } | |
| 1080 | 1063 | return 0; | |
| 1081 | 1064 | } | |
@@ -1245,13 +1228,8 @@ void Http2Session::HandleDataFrame(const nghttp2_frame* frame) { | |||
| 1245 | 1228 | DEBUG_HTTP2SESSION2(this, "handling data frame for stream %d", id); | |
| 1246 | 1229 | Http2Stream* stream = FindStream(id); | |
| 1247 | 1230 | ||
| 1248 | - // If the stream has already been destroyed, do nothing | ||
| 1249 | - if (stream->IsDestroyed()) | ||
| 1250 | - return; | ||
| 1251 | - | ||
| 1252 | - if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) { | ||
| 1231 | + if (!stream->IsDestroyed() && frame->hd.flags & NGHTTP2_FLAG_END_STREAM) | ||
| 1253 | 1232 | stream->EmitRead(UV_EOF); | |
| 1254 | - } | ||
| 1255 | 1233 | } | |
| 1256 | 1234 | ||
| 1257 | 1235 | ||
@@ -1326,11 +1304,8 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) { | |||
| 1326 | 1304 | HandleScope scope(isolate); | |
| 1327 | 1305 | Local<Context> context = env()->context(); | |
| 1328 | 1306 | Context::Scope context_scope(context); | |
| 1329 | - | ||
| 1330 | - Local<Value> argv[1] = { | ||
| 1331 | - Integer::New(isolate, NGHTTP2_ERR_PROTO), | ||
| 1332 | - }; | ||
| 1333 | - MakeCallback(env()->error_string(), arraysize(argv), argv); | ||
| 1307 | + Local<Value> arg = Integer::New(isolate, NGHTTP2_ERR_PROTO); | ||
| 1308 | + MakeCallback(env()->error_string(), 1, &arg); | ||
| 1334 | 1309 | } | |
| 1335 | 1310 | } | |
| 1336 | 1311 | } | |
@@ -1358,11 +1333,8 @@ void Http2Session::HandleSettingsFrame(const nghttp2_frame* frame) { | |||
| 1358 | 1333 | HandleScope scope(isolate); | |
| 1359 | 1334 | Local<Context> context = env()->context(); | |
| 1360 | 1335 | Context::Scope context_scope(context); | |
| 1361 | - | ||
| 1362 | - Local<Value> argv[1] = { | ||
| 1363 | - Integer::New(isolate, NGHTTP2_ERR_PROTO), | ||
| 1364 | - }; | ||
| 1365 | - MakeCallback(env()->error_string(), arraysize(argv), argv); | ||
| 1336 | + Local<Value> arg = Integer::New(isolate, NGHTTP2_ERR_PROTO); | ||
| 1337 | + MakeCallback(env()->error_string(), 1, &arg); | ||
| 1366 | 1338 | } | |
| 1367 | 1339 | } else { | |
| 1368 | 1340 | // Otherwise, notify the session about a new settings | |
@@ -1782,7 +1754,7 @@ int Http2Stream::DoShutdown(ShutdownWrap* req_wrap) { | |||
| 1782 | 1754 | { | |
| 1783 | 1755 | Http2Scope h2scope(this); | |
| 1784 | 1756 | flags_ |= NGHTTP2_STREAM_FLAG_SHUT; | |
| 1785 | - CHECK_NE(nghttp2_session_resume_data(session_->session(), id_), | ||
| 1757 | + CHECK_NE(nghttp2_session_resume_data(**session_, id_), | ||
| 1786 | 1758 | NGHTTP2_ERR_NOMEM); | |
| 1787 | 1759 | DEBUG_HTTP2STREAM(this, "writable side shutdown"); | |
| 1788 | 1760 | } | |
@@ -1843,7 +1815,7 @@ int Http2Stream::SubmitResponse(nghttp2_nv* nva, size_t len, int options) { | |||
| 1843 | 1815 | options |= STREAM_OPTION_EMPTY_PAYLOAD; | |
| 1844 | 1816 | ||
| 1845 | 1817 | Http2Stream::Provider::Stream prov(this, options); | |
| 1846 | - int ret = nghttp2_submit_response(session_->session(), id_, nva, len, *prov); | ||
| 1818 | + int ret = nghttp2_submit_response(**session_, id_, nva, len, *prov); | ||
| 1847 | 1819 | CHECK_NE(ret, NGHTTP2_ERR_NOMEM); | |
| 1848 | 1820 | return ret; | |
| 1849 | 1821 | } | |
@@ -1876,7 +1848,7 @@ int Http2Stream::SubmitInfo(nghttp2_nv* nva, size_t len) { | |||
| 1876 | 1848 | CHECK(!this->IsDestroyed()); | |
| 1877 | 1849 | Http2Scope h2scope(this); | |
| 1878 | 1850 | DEBUG_HTTP2STREAM2(this, "sending %d informational headers", len); | |
| 1879 | - int ret = nghttp2_submit_headers(session_->session(), | ||
| 1851 | + int ret = nghttp2_submit_headers(**session_, | ||
| 1880 | 1852 | NGHTTP2_FLAG_NONE, | |
| 1881 | 1853 | id_, nullptr, | |
| 1882 | 1854 | nva, len, nullptr); | |
@@ -1891,9 +1863,9 @@ int Http2Stream::SubmitPriority(nghttp2_priority_spec* prispec, | |||
| 1891 | 1863 | Http2Scope h2scope(this); | |
| 1892 | 1864 | DEBUG_HTTP2STREAM(this, "sending priority spec"); | |
| 1893 | 1865 | int ret = silent ? | |
| 1894 | - nghttp2_session_change_stream_priority(session_->session(), | ||
| 1866 | + nghttp2_session_change_stream_priority(**session_, | ||
| 1895 | 1867 | id_, prispec) : | |
| 1896 | - nghttp2_submit_priority(session_->session(), | ||
| 1868 | + nghttp2_submit_priority(**session_, | ||
| 1897 | 1869 | NGHTTP2_FLAG_NONE, | |
| 1898 | 1870 | id_, prispec); | |
| 1899 | 1871 | CHECK_NE(ret, NGHTTP2_ERR_NOMEM); | |
@@ -1943,7 +1915,7 @@ int Http2Stream::ReadStart() { | |||
| 1943 | 1915 | ||
| 1944 | 1916 | // Tell nghttp2 about our consumption of the data that was handed | |
| 1945 | 1917 | // off to JS land. | |
| 1946 | - nghttp2_session_consume_stream(session_->session(), | ||
| 1918 | + nghttp2_session_consume_stream(**session_, | ||
| 1947 | 1919 | id_, | |
| 1948 | 1920 | inbound_consumed_data_while_paused_); | |
| 1949 | 1921 | inbound_consumed_data_while_paused_ = 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments