@@ -210,7 +210,7 @@ Http2Options::Http2Options(Environment* env, nghttp2_session_type type) {
210
210
// Important: The maxSessionMemory option in javascript is expressed in
211
211
// terms of MB increments (i.e. the value 1 == 1 MB)
212
212
if (flags & (1 << IDX_OPTIONS_MAX_SESSION_MEMORY))
213
- SetMaxSessionMemory (buffer[IDX_OPTIONS_MAX_SESSION_MEMORY] * 1e6 );
213
+ SetMaxSessionMemory (buffer[IDX_OPTIONS_MAX_SESSION_MEMORY] * 1000000 );
214
214
}
215
215
216
216
void Http2Session::Http2Settings::Init () {
@@ -350,8 +350,8 @@ Http2Priority::Http2Priority(Environment* env,
350
350
int32_t weight_ = weight->Int32Value (context).ToChecked ();
351
351
bool exclusive_ = exclusive->BooleanValue (env->isolate ());
352
352
Debug (env, DebugCategory::HTTP2STREAM,
353
- " Http2Priority: parent: %d, weight: %d, exclusive: %d \n " ,
354
- parent_, weight_, exclusive_);
353
+ " Http2Priority: parent: %d, weight: %d, exclusive: %s \n " ,
354
+ parent_, weight_, exclusive_ ? " yes " : " no " );
355
355
nghttp2_priority_spec_init (&spec, parent_, weight_, exclusive_ ? 1 : 0 );
356
356
}
357
357
@@ -579,8 +579,10 @@ void Http2Stream::EmitStatistics() {
579
579
} else {
580
580
buffer[IDX_STREAM_STATS_TIMETOFIRSTBYTESENT] = 0 ;
581
581
}
582
- buffer[IDX_STREAM_STATS_SENTBYTES] = entry->sent_bytes ();
583
- buffer[IDX_STREAM_STATS_RECEIVEDBYTES] = entry->received_bytes ();
582
+ buffer[IDX_STREAM_STATS_SENTBYTES] =
583
+ static_cast <double >(entry->sent_bytes ());
584
+ buffer[IDX_STREAM_STATS_RECEIVEDBYTES] =
585
+ static_cast <double >(entry->received_bytes ());
584
586
Local<Object> obj;
585
587
if (entry->ToObject ().ToLocal (&obj)) entry->Notify (obj);
586
588
});
@@ -603,10 +605,12 @@ void Http2Session::EmitStatistics() {
603
605
buffer[IDX_SESSION_STATS_STREAMCOUNT] = entry->stream_count ();
604
606
buffer[IDX_SESSION_STATS_STREAMAVERAGEDURATION] =
605
607
entry->stream_average_duration ();
606
- buffer[IDX_SESSION_STATS_DATA_SENT] = entry->data_sent ();
607
- buffer[IDX_SESSION_STATS_DATA_RECEIVED] = entry->data_received ();
608
+ buffer[IDX_SESSION_STATS_DATA_SENT] =
609
+ static_cast <double >(entry->data_sent ());
610
+ buffer[IDX_SESSION_STATS_DATA_RECEIVED] =
611
+ static_cast <double >(entry->data_received ());
608
612
buffer[IDX_SESSION_STATS_MAX_CONCURRENT_STREAMS] =
609
- entry->max_concurrent_streams ();
613
+ static_cast < double >( entry->max_concurrent_streams () );
610
614
Local<Object> obj;
611
615
if (entry->ToObject ().ToLocal (&obj)) entry->Notify (obj);
612
616
});
@@ -1514,9 +1518,9 @@ void Http2Session::ClearOutgoing(int status) {
1514
1518
outgoing_storage_.clear ();
1515
1519
outgoing_length_ = 0 ;
1516
1520
1517
- std::vector<nghttp2_stream_write > current_outgoing_buffers_;
1521
+ std::vector<NgHttp2StreamWrite > current_outgoing_buffers_;
1518
1522
current_outgoing_buffers_.swap (outgoing_buffers_);
1519
- for (const nghttp2_stream_write & wr : current_outgoing_buffers_) {
1523
+ for (const NgHttp2StreamWrite & wr : current_outgoing_buffers_) {
1520
1524
WriteWrap* wrap = wr.req_wrap ;
1521
1525
if (wrap != nullptr ) {
1522
1526
// TODO(addaleax): Pass `status` instead of 0, so that we actually error
@@ -1543,7 +1547,7 @@ void Http2Session::ClearOutgoing(int status) {
1543
1547
}
1544
1548
}
1545
1549
1546
- void Http2Session::PushOutgoingBuffer (nghttp2_stream_write && write) {
1550
+ void Http2Session::PushOutgoingBuffer (NgHttp2StreamWrite && write) {
1547
1551
outgoing_length_ += write .buf .len ;
1548
1552
outgoing_buffers_.emplace_back (std::move (write ));
1549
1553
}
@@ -1560,7 +1564,7 @@ void Http2Session::CopyDataIntoOutgoing(const uint8_t* src, size_t src_length) {
1560
1564
// of the outgoing_buffers_ vector may invalidate the pointer.
1561
1565
// The correct base pointers will be set later, before writing to the
1562
1566
// underlying socket.
1563
- PushOutgoingBuffer (nghttp2_stream_write {
1567
+ PushOutgoingBuffer (NgHttp2StreamWrite {
1564
1568
uv_buf_init (nullptr , src_length)
1565
1569
});
1566
1570
}
@@ -1623,7 +1627,7 @@ uint8_t Http2Session::SendPendingData() {
1623
1627
// (Those are marked by having .base == nullptr.)
1624
1628
size_t offset = 0 ;
1625
1629
size_t i = 0 ;
1626
- for (const nghttp2_stream_write & write : outgoing_buffers_) {
1630
+ for (const NgHttp2StreamWrite & write : outgoing_buffers_) {
1627
1631
statistics_.data_sent += write .buf .len ;
1628
1632
if (write .buf .base == nullptr ) {
1629
1633
bufs[i++] = uv_buf_init (
@@ -1679,7 +1683,7 @@ int Http2Session::OnSendData(
1679
1683
// we told it so, which means that we *should* have data available.
1680
1684
CHECK (!stream->queue_ .empty ());
1681
1685
1682
- nghttp2_stream_write & write = stream->queue_ .front ();
1686
+ NgHttp2StreamWrite & write = stream->queue_ .front ();
1683
1687
if (write .buf .len <= length) {
1684
1688
// This write does not suffice by itself, so we can consume it completely.
1685
1689
length -= write .buf .len ;
@@ -1689,7 +1693,7 @@ int Http2Session::OnSendData(
1689
1693
}
1690
1694
1691
1695
// Slice off `length` bytes of the first write in the queue.
1692
- session->PushOutgoingBuffer (nghttp2_stream_write {
1696
+ session->PushOutgoingBuffer (NgHttp2StreamWrite {
1693
1697
uv_buf_init (write .buf .base , length)
1694
1698
});
1695
1699
write .buf .base += length;
@@ -1699,7 +1703,7 @@ int Http2Session::OnSendData(
1699
1703
1700
1704
if (frame->data .padlen > 0 ) {
1701
1705
// Send padding if that was requested.
1702
- session->PushOutgoingBuffer (nghttp2_stream_write {
1706
+ session->PushOutgoingBuffer (NgHttp2StreamWrite {
1703
1707
uv_buf_init (const_cast <char *>(zero_bytes_256), frame->data .padlen - 1 )
1704
1708
});
1705
1709
}
@@ -1780,7 +1784,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
1780
1784
1781
1785
// Remember the current buffer, so that OnDataChunkReceived knows the
1782
1786
// offset of a DATA frame's data into the socket read buffer.
1783
- stream_buf_ = uv_buf_init (buf.data (), nread);
1787
+ stream_buf_ = uv_buf_init (buf.data (), static_cast < unsigned int >( nread) );
1784
1788
1785
1789
Isolate* isolate = env ()->isolate ();
1786
1790
@@ -1793,7 +1797,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
1793
1797
1794
1798
if (UNLIKELY (ret < 0 )) {
1795
1799
Debug (this , " fatal error receiving data: %d" , ret);
1796
- Local<Value> arg = Integer::New (isolate, ret);
1800
+ Local<Value> arg = Integer::New (isolate, static_cast < int32_t >( ret) );
1797
1801
MakeCallback (env ()->http2session_on_error_function (), 1 , &arg);
1798
1802
return ;
1799
1803
}
@@ -1802,7 +1806,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
1802
1806
}
1803
1807
1804
1808
bool Http2Session::HasWritesOnSocketForStream (Http2Stream* stream) {
1805
- for (const nghttp2_stream_write & wr : outgoing_buffers_) {
1809
+ for (const NgHttp2StreamWrite & wr : outgoing_buffers_) {
1806
1810
if (wr.req_wrap != nullptr && wr.req_wrap ->stream () == stream)
1807
1811
return true ;
1808
1812
}
@@ -1949,7 +1953,7 @@ void Http2Stream::Destroy() {
1949
1953
// here because it's possible for destroy to have been called while
1950
1954
// we still have queued outbound writes.
1951
1955
while (!queue_.empty ()) {
1952
- nghttp2_stream_write & head = queue_.front ();
1956
+ NgHttp2StreamWrite & head = queue_.front ();
1953
1957
if (head.req_wrap != nullptr )
1954
1958
head.req_wrap ->Done (UV_ECANCELED);
1955
1959
queue_.pop ();
@@ -2167,7 +2171,7 @@ int Http2Stream::DoWrite(WriteWrap* req_wrap,
2167
2171
for (size_t i = 0 ; i < nbufs; ++i) {
2168
2172
// Store the req_wrap on the last write info in the queue, so that it is
2169
2173
// only marked as finished once all buffers associated with it are finished.
2170
- queue_.emplace (nghttp2_stream_write {
2174
+ queue_.emplace (NgHttp2StreamWrite {
2171
2175
i == nbufs - 1 ? req_wrap : nullptr ,
2172
2176
bufs[i]
2173
2177
});
@@ -2403,19 +2407,19 @@ void Http2Session::RefreshState(const FunctionCallbackInfo<Value>& args) {
2403
2407
buffer[IDX_SESSION_STATE_REMOTE_WINDOW_SIZE] =
2404
2408
nghttp2_session_get_remote_window_size (s);
2405
2409
buffer[IDX_SESSION_STATE_OUTBOUND_QUEUE_SIZE] =
2406
- nghttp2_session_get_outbound_queue_size (s);
2410
+ static_cast < double >( nghttp2_session_get_outbound_queue_size (s) );
2407
2411
buffer[IDX_SESSION_STATE_HD_DEFLATE_DYNAMIC_TABLE_SIZE] =
2408
- nghttp2_session_get_hd_deflate_dynamic_table_size (s);
2412
+ static_cast < double >( nghttp2_session_get_hd_deflate_dynamic_table_size (s) );
2409
2413
buffer[IDX_SESSION_STATE_HD_INFLATE_DYNAMIC_TABLE_SIZE] =
2410
- nghttp2_session_get_hd_inflate_dynamic_table_size (s);
2414
+ static_cast < double >( nghttp2_session_get_hd_inflate_dynamic_table_size (s) );
2411
2415
}
2412
2416
2413
2417
2414
2418
// Constructor for new Http2Session instances.
2415
2419
void Http2Session::New (const FunctionCallbackInfo<Value>& args) {
2416
2420
Environment* env = Environment::GetCurrent (args);
2417
2421
CHECK (args.IsConstructCall ());
2418
- int val = args[0 ]->IntegerValue (env->context ()).ToChecked ();
2422
+ int32_t val = args[0 ]->Int32Value (env->context ()).ToChecked ();
2419
2423
nghttp2_session_type type = static_cast <nghttp2_session_type>(val);
2420
2424
Http2Session* session = new Http2Session (env, args.This (), type);
2421
2425
session->get_async_id (); // avoid compiler warning
@@ -2453,7 +2457,7 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
2453
2457
Environment* env = session->env ();
2454
2458
2455
2459
Local<Array> headers = args[0 ].As <Array>();
2456
- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2460
+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
2457
2461
Http2Priority priority (env, args[2 ], args[3 ], args[4 ]);
2458
2462
2459
2463
Debug (session, " request submitted" );
@@ -2464,7 +2468,7 @@ void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
2464
2468
*priority,
2465
2469
Http2Headers (env, headers),
2466
2470
&ret,
2467
- options);
2471
+ static_cast < int >( options) );
2468
2472
2469
2473
if (ret <= 0 || stream == nullptr ) {
2470
2474
Debug (session, " could not submit request: %s" , nghttp2_strerror (ret));
@@ -2553,10 +2557,12 @@ void Http2Stream::Respond(const FunctionCallbackInfo<Value>& args) {
2553
2557
ASSIGN_OR_RETURN_UNWRAP (&stream, args.Holder ());
2554
2558
2555
2559
Local<Array> headers = args[0 ].As <Array>();
2556
- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2560
+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
2557
2561
2558
2562
args.GetReturnValue ().Set (
2559
- stream->SubmitResponse (Http2Headers (env, headers), options));
2563
+ stream->SubmitResponse (
2564
+ Http2Headers (env, headers),
2565
+ static_cast <int >(options)));
2560
2566
Debug (stream, " response submitted" );
2561
2567
}
2562
2568
@@ -2606,13 +2612,16 @@ void Http2Stream::PushPromise(const FunctionCallbackInfo<Value>& args) {
2606
2612
ASSIGN_OR_RETURN_UNWRAP (&parent, args.Holder ());
2607
2613
2608
2614
Local<Array> headers = args[0 ].As <Array>();
2609
- int options = args[1 ]->IntegerValue (env->context ()).ToChecked ();
2615
+ int32_t options = args[1 ]->Int32Value (env->context ()).ToChecked ();
2610
2616
2611
2617
Debug (parent, " creating push promise" );
2612
2618
2613
2619
int32_t ret = 0 ;
2614
2620
Http2Stream* stream =
2615
- parent->SubmitPushPromise (Http2Headers (env, headers), &ret, options);
2621
+ parent->SubmitPushPromise (
2622
+ Http2Headers (env, headers),
2623
+ &ret,
2624
+ static_cast <int >(options));
2616
2625
2617
2626
if (ret <= 0 || stream == nullptr ) {
2618
2627
Debug (parent, " failed to create push stream: %d" , ret);
@@ -2726,13 +2735,13 @@ void Http2Session::Origin(const FunctionCallbackInfo<Value>& args) {
2726
2735
ASSIGN_OR_RETURN_UNWRAP (&session, args.Holder ());
2727
2736
2728
2737
Local<String> origin_string = args[0 ].As <String>();
2729
- int count = args[1 ]->IntegerValue (context).ToChecked ();
2738
+ int32_t count = args[1 ]->Int32Value (context).ToChecked ();
2730
2739
2731
2740
2732
2741
Origins origins (env->isolate (),
2733
2742
env->context (),
2734
2743
origin_string,
2735
- count);
2744
+ static_cast < int >( count) );
2736
2745
2737
2746
session->Origin (*origins, origins.length ());
2738
2747
}
@@ -2886,7 +2895,7 @@ void Http2Session::Http2Ping::DetachFromSession() {
2886
2895
session_ = nullptr ;
2887
2896
}
2888
2897
2889
- void nghttp2_stream_write ::MemoryInfo (MemoryTracker* tracker) const {
2898
+ void NgHttp2StreamWrite ::MemoryInfo (MemoryTracker* tracker) const {
2890
2899
if (req_wrap != nullptr )
2891
2900
tracker->TrackField (" req_wrap" , req_wrap->GetAsyncWrap ());
2892
2901
tracker->TrackField (" buf" , buf);
0 commit comments