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