@@ -209,7 +209,7 @@ Http2Options::Http2Options(Environment* env, nghttp2_session_type type) {
209209 // Important: The maxSessionMemory option in javascript is expressed in
210210 // terms of MB increments (i.e. the value 1 == 1 MB)
211211 if (flags & (1 << IDX_OPTIONS_MAX_SESSION_MEMORY))
212- SetMaxSessionMemory (buffer[IDX_OPTIONS_MAX_SESSION_MEMORY] * 1e6 );
212+ SetMaxSessionMemory (buffer[IDX_OPTIONS_MAX_SESSION_MEMORY] * 1000000 );
213213}
214214
215215void Http2Session::Http2Settings::Init () {
@@ -349,8 +349,8 @@ Http2Priority::Http2Priority(Environment* env,
349349 int32_t weight_ = weight->Int32Value (context).ToChecked ();
350350 bool exclusive_ = exclusive->BooleanValue (env->isolate ());
351351 Debug (env, DebugCategory::HTTP2STREAM,
352- " Http2Priority: parent: %d, weight: %d, exclusive: %d \n " ,
353- parent_, weight_, exclusive_);
352+ " Http2Priority: parent: %d, weight: %d, exclusive: %s \n " ,
353+ parent_, weight_, exclusive_ ? " yes " : " no " );
354354 nghttp2_priority_spec_init (&spec, parent_, weight_, exclusive_ ? 1 : 0 );
355355}
356356
@@ -578,8 +578,10 @@ void Http2Stream::EmitStatistics() {
578578 } else {
579579 buffer[IDX_STREAM_STATS_TIMETOFIRSTBYTESENT] = 0 ;
580580 }
581- buffer[IDX_STREAM_STATS_SENTBYTES] = entry->sent_bytes ();
582- buffer[IDX_STREAM_STATS_RECEIVEDBYTES] = entry->received_bytes ();
581+ buffer[IDX_STREAM_STATS_SENTBYTES] =
582+ static_cast <double >(entry->sent_bytes ());
583+ buffer[IDX_STREAM_STATS_RECEIVEDBYTES] =
584+ static_cast <double >(entry->received_bytes ());
583585 Local<Object> obj;
584586 if (entry->ToObject ().ToLocal (&obj)) entry->Notify (obj);
585587 });
@@ -602,10 +604,12 @@ void Http2Session::EmitStatistics() {
602604 buffer[IDX_SESSION_STATS_STREAMCOUNT] = entry->stream_count ();
603605 buffer[IDX_SESSION_STATS_STREAMAVERAGEDURATION] =
604606 entry->stream_average_duration ();
605- buffer[IDX_SESSION_STATS_DATA_SENT] = entry->data_sent ();
606- buffer[IDX_SESSION_STATS_DATA_RECEIVED] = entry->data_received ();
607+ buffer[IDX_SESSION_STATS_DATA_SENT] =
608+ static_cast <double >(entry->data_sent ());
609+ buffer[IDX_SESSION_STATS_DATA_RECEIVED] =
610+ static_cast <double >(entry->data_received ());
607611 buffer[IDX_SESSION_STATS_MAX_CONCURRENT_STREAMS] =
608- entry->max_concurrent_streams ();
612+ static_cast < double >( entry->max_concurrent_streams () );
609613 Local<Object> obj;
610614 if (entry->ToObject ().ToLocal (&obj)) entry->Notify (obj);
611615 });
@@ -1513,9 +1517,9 @@ void Http2Session::ClearOutgoing(int status) {
15131517 outgoing_storage_.clear ();
15141518 outgoing_length_ = 0 ;
15151519
1516- std::vector<nghttp2_stream_write > current_outgoing_buffers_;
1520+ std::vector<NgHttp2StreamWrite > current_outgoing_buffers_;
15171521 current_outgoing_buffers_.swap (outgoing_buffers_);
1518- for (const nghttp2_stream_write & wr : current_outgoing_buffers_) {
1522+ for (const NgHttp2StreamWrite & wr : current_outgoing_buffers_) {
15191523 WriteWrap* wrap = wr.req_wrap ;
15201524 if (wrap != nullptr ) {
15211525 // TODO(addaleax): Pass `status` instead of 0, so that we actually error
@@ -1542,7 +1546,7 @@ void Http2Session::ClearOutgoing(int status) {
15421546 }
15431547}
15441548
1545- void Http2Session::PushOutgoingBuffer (nghttp2_stream_write && write) {
1549+ void Http2Session::PushOutgoingBuffer (NgHttp2StreamWrite && write) {
15461550 outgoing_length_ += write.buf .len ;
15471551 outgoing_buffers_.emplace_back (std::move (write));
15481552}
@@ -1559,7 +1563,7 @@ void Http2Session::CopyDataIntoOutgoing(const uint8_t* src, size_t src_length) {
15591563 // of the outgoing_buffers_ vector may invalidate the pointer.
15601564 // The correct base pointers will be set later, before writing to the
15611565 // underlying socket.
1562- PushOutgoingBuffer (nghttp2_stream_write {
1566+ PushOutgoingBuffer (NgHttp2StreamWrite {
15631567 uv_buf_init (nullptr , src_length)
15641568 });
15651569}
@@ -1622,7 +1626,7 @@ uint8_t Http2Session::SendPendingData() {
16221626 // (Those are marked by having .base == nullptr.)
16231627 size_t offset = 0 ;
16241628 size_t i = 0 ;
1625- for (const nghttp2_stream_write & write : outgoing_buffers_) {
1629+ for (const NgHttp2StreamWrite & write : outgoing_buffers_) {
16261630 statistics_.data_sent += write.buf .len ;
16271631 if (write.buf .base == nullptr ) {
16281632 bufs[i++] = uv_buf_init (
@@ -1678,7 +1682,7 @@ int Http2Session::OnSendData(
16781682 // we told it so, which means that we *should* have data available.
16791683 CHECK (!stream->queue_ .empty ());
16801684
1681- nghttp2_stream_write & write = stream->queue_ .front ();
1685+ NgHttp2StreamWrite & write = stream->queue_ .front ();
16821686 if (write.buf .len <= length) {
16831687 // This write does not suffice by itself, so we can consume it completely.
16841688 length -= write.buf .len ;
@@ -1688,7 +1692,7 @@ int Http2Session::OnSendData(
16881692 }
16891693
16901694 // Slice off `length` bytes of the first write in the queue.
1691- session->PushOutgoingBuffer (nghttp2_stream_write {
1695+ session->PushOutgoingBuffer (NgHttp2StreamWrite {
16921696 uv_buf_init (write.buf .base , length)
16931697 });
16941698 write.buf .base += length;
@@ -1698,7 +1702,7 @@ int Http2Session::OnSendData(
16981702
16991703 if (frame->data .padlen > 0 ) {
17001704 // Send padding if that was requested.
1701- session->PushOutgoingBuffer (nghttp2_stream_write {
1705+ session->PushOutgoingBuffer (NgHttp2StreamWrite {
17021706 uv_buf_init (const_cast <char *>(zero_bytes_256), frame->data .padlen - 1 )
17031707 });
17041708 }
@@ -1779,7 +1783,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
17791783
17801784 // Remember the current buffer, so that OnDataChunkReceived knows the
17811785 // offset of a DATA frame's data into the socket read buffer.
1782- stream_buf_ = uv_buf_init (buf.data (), nread);
1786+ stream_buf_ = uv_buf_init (buf.data (), static_cast < unsigned int >( nread) );
17831787
17841788 Isolate* isolate = env ()->isolate ();
17851789
@@ -1792,7 +1796,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
17921796
17931797 if (UNLIKELY (ret < 0 )) {
17941798 Debug (this , " fatal error receiving data: %d" , ret);
1795- Local<Value> arg = Integer::New (isolate, ret);
1799+ Local<Value> arg = Integer::New (isolate, static_cast < int32_t >( ret) );
17961800 MakeCallback (env ()->http2session_on_error_function (), 1 , &arg);
17971801 return ;
17981802 }
@@ -1801,7 +1805,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
18011805}
18021806
18031807bool Http2Session::HasWritesOnSocketForStream (Http2Stream* stream) {
1804- for (const nghttp2_stream_write & wr : outgoing_buffers_) {
1808+ for (const NgHttp2StreamWrite & wr : outgoing_buffers_) {
18051809 if (wr.req_wrap != nullptr && wr.req_wrap ->stream () == stream)
18061810 return true ;
18071811 }
@@ -1948,7 +1952,7 @@ void Http2Stream::Destroy() {
19481952 // here because it's possible for destroy to have been called while
19491953 // we still have queued outbound writes.
19501954 while (!queue_.empty ()) {
1951- nghttp2_stream_write & head = queue_.front ();
1955+ NgHttp2StreamWrite & head = queue_.front ();
19521956 if (head.req_wrap != nullptr )
19531957 head.req_wrap ->Done (UV_ECANCELED);
19541958 queue_.pop ();
@@ -2166,7 +2170,7 @@ int Http2Stream::DoWrite(WriteWrap* req_wrap,
21662170 for (size_t i = 0 ; i < nbufs; ++i) {
21672171 // Store the req_wrap on the last write info in the queue, so that it is
21682172 // only marked as finished once all buffers associated with it are finished.
2169- queue_.emplace (nghttp2_stream_write {
2173+ queue_.emplace (NgHttp2StreamWrite {
21702174 i == nbufs - 1 ? req_wrap : nullptr ,
21712175 bufs[i]
21722176 });
@@ -2402,19 +2406,19 @@ void Http2Session::RefreshState(const FunctionCallbackInfo<Value>& args) {
24022406 buffer[IDX_SESSION_STATE_REMOTE_WINDOW_SIZE] =
24032407 nghttp2_session_get_remote_window_size (s);
24042408 buffer[IDX_SESSION_STATE_OUTBOUND_QUEUE_SIZE] =
2405- nghttp2_session_get_outbound_queue_size (s);
2409+ static_cast < double >( nghttp2_session_get_outbound_queue_size (s) );
24062410 buffer[IDX_SESSION_STATE_HD_DEFLATE_DYNAMIC_TABLE_SIZE] =
2407- nghttp2_session_get_hd_deflate_dynamic_table_size (s);
2411+ static_cast < double >( nghttp2_session_get_hd_deflate_dynamic_table_size (s) );
24082412 buffer[IDX_SESSION_STATE_HD_INFLATE_DYNAMIC_TABLE_SIZE] =
2409- nghttp2_session_get_hd_inflate_dynamic_table_size (s);
2413+ static_cast < double >( nghttp2_session_get_hd_inflate_dynamic_table_size (s) );
24102414}
24112415
24122416
24132417// Constructor for new Http2Session instances.
24142418void Http2Session::New (const FunctionCallbackInfo<Value>& args) {
24152419 Environment* env = Environment::GetCurrent (args);
24162420 CHECK (args.IsConstructCall ());
2417- int val = args[0 ]->IntegerValue (env->context ()).ToChecked ();
2421+ int32_t val = args[0 ]->Int32Value (env->context ()).ToChecked ();
24182422 nghttp2_session_type type = static_cast <nghttp2_session_type>(val);
24192423 Http2Session* session = new Http2Session (env, args.This (), type);
24202424 session->get_async_id (); // avoid compiler warning
@@ -2452,7 +2456,7 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
24522456 Environment* env = session->env ();
24532457
24542458 Local<Array> headers = args[0 ].As <Array>();
2455- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2459+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
24562460 Http2Priority priority (env, args[2 ], args[3 ], args[4 ]);
24572461
24582462 Debug (session, " request submitted" );
@@ -2463,7 +2467,7 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
24632467 *priority,
24642468 Http2Headers (env, headers),
24652469 &ret,
2466- options);
2470+ static_cast < int >( options) );
24672471
24682472 if (ret <= 0 || stream == nullptr ) {
24692473 Debug (session, " could not submit request: %s" , nghttp2_strerror (ret));
@@ -2552,10 +2556,12 @@ void Http2Stream::Respond(const FunctionCallbackInfo<Value>& args) {
25522556 ASSIGN_OR_RETURN_UNWRAP (&stream, args.Holder ());
25532557
25542558 Local<Array> headers = args[0 ].As <Array>();
2555- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2559+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
25562560
25572561 args.GetReturnValue ().Set (
2558- stream->SubmitResponse (Http2Headers (env, headers), options));
2562+ stream->SubmitResponse (
2563+ Http2Headers (env, headers),
2564+ static_cast <int >(options)));
25592565 Debug (stream, " response submitted" );
25602566}
25612567
@@ -2605,13 +2611,16 @@ void Http2Stream::PushPromise(const FunctionCallbackInfo<Value>& args) {
26052611 ASSIGN_OR_RETURN_UNWRAP (&parent, args.Holder ());
26062612
26072613 Local<Array> headers = args[0 ].As <Array>();
2608- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2614+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
26092615
26102616 Debug (parent, " creating push promise" );
26112617
26122618 int32_t ret = 0 ;
26132619 Http2Stream* stream =
2614- parent->SubmitPushPromise (Http2Headers (env, headers), &ret, options);
2620+ parent->SubmitPushPromise (
2621+ Http2Headers (env, headers),
2622+ &ret,
2623+ static_cast <int >(options));
26152624
26162625 if (ret <= 0 || stream == nullptr ) {
26172626 Debug (parent, " failed to create push stream: %d" , ret);
@@ -2725,13 +2734,13 @@ void Http2Session::Origin(const FunctionCallbackInfo<Value>& args) {
27252734 ASSIGN_OR_RETURN_UNWRAP (&session, args.Holder ());
27262735
27272736 Local<String> origin_string = args[0 ].As <String>();
2728- int count = args[1 ]->IntegerValue (context).ToChecked ();
2737+ int32_t count = args[1 ]->Int32Value (context).ToChecked ();
27292738
27302739
27312740 Origins origins (env->isolate (),
27322741 env->context (),
27332742 origin_string,
2734- count);
2743+ static_cast < int >( count) );
27352744
27362745 session->Origin (*origins, origins.length ());
27372746}
@@ -2885,7 +2894,7 @@ void Http2Session::Http2Ping::DetachFromSession() {
28852894 session_ = nullptr ;
28862895}
28872896
2888- void nghttp2_stream_write ::MemoryInfo (MemoryTracker* tracker) const {
2897+ void NgHttp2StreamWrite ::MemoryInfo (MemoryTracker* tracker) const {
28892898 if (req_wrap != nullptr )
28902899 tracker->TrackField (" req_wrap" , req_wrap->GetAsyncWrap ());
28912900 tracker->TrackField (" buf" , buf);
0 commit comments