Skip to content

Commit

Permalink
quic: hopefully fixup windows build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed May 10, 2023
1 parent ee923ac commit a325de7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
5 changes: 2 additions & 3 deletions src/quic/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "application.h"
#include <node_sockaddr-inl.h>
#include <v8.h>
#include "defs.h"
#include "endpoint.h"
#include "packet.h"
#include "session.h"
Expand Down Expand Up @@ -378,9 +379,7 @@ class DefaultApplication final : public Session::Application {
return i == cnt;
};

if (!stream_data.stream || !is_empty(stream_data.buf, stream_data.count))
return false;
return true;
return stream_data.stream && is_empty(stream_data.buf, stream_data.count);
}

bool StreamCommit(StreamData* stream_data, size_t datalen) override {
Expand Down
2 changes: 1 addition & 1 deletion src/quic/bindingdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ constexpr size_t kMaxVectorCount = 16;
V(max_connections_total, "maxConnectionsTotal") \
V(max_datagram_frame_size, "maxDatagramFrameSize") \
V(max_field_section_size, "maxFieldSectionSize") \
V(max_header_length, "maxHeaderLength"); \
V(max_header_length, "maxHeaderLength") \
V(max_header_pairs, "maxHeaderPairs") \
V(max_idle_timeout, "maxIdleTimeout") \
V(max_payload_size, "maxPayloadSize") \
Expand Down
4 changes: 2 additions & 2 deletions src/quic/endpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class Endpoint::UDP::Impl final : public HandleWrap {
return;
}

impl->endpoint_->Receive(uv_buf_t{buf->base, static_cast<size_t>(nread)},
impl->endpoint_->Receive(uv_buf_init(buf->base, static_cast<size_t>(nread)),
SocketAddress(addr));
}

Expand Down Expand Up @@ -459,7 +459,7 @@ void Endpoint::Initialize(Environment* env, Local<Object> target) {
#undef V

#define V(name, key, __) \
auto IDX_STATE_ENDPOINT_##name = OffsetOf(&Endpoint::State::key);
auto IDX_STATE_ENDPOINT_##name = offsetof(Endpoint::State, key);
ENDPOINT_STATE(V)
#undef V

Expand Down
2 changes: 1 addition & 1 deletion src/quic/endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ class Endpoint final : public AsyncWrap, public Packet::Listener {
SET_MEMORY_INFO_NAME(Endpoint)
SET_SELF_SIZE(Endpoint)

private:
struct Stats;
struct State;

private:
class UDP final : public MemoryRetainer {
public:
explicit UDP(Endpoint* endpoint);
Expand Down
6 changes: 3 additions & 3 deletions src/quic/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) {
switch (family) {
case AF_INET: {
auto ipv4 = preferredAddress->ipv4();
if (ipv4 != std::nullopt) {
if (ipv4.has_value()) {
if (ipv4->address.empty() || ipv4->port == 0) return;
SocketAddress::New(AF_INET,
std::string(ipv4->address).c_str(),
Expand All @@ -1285,7 +1285,7 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) {
}
case AF_INET6: {
auto ipv6 = preferredAddress->ipv6();
if (ipv6 != std::nullopt) {
if (ipv6.has_value()) {
if (ipv6->address.empty() || ipv6->port == 0) return;
SocketAddress::New(AF_INET,
std::string(ipv6->address).c_str(),
Expand Down Expand Up @@ -2133,7 +2133,7 @@ void Session::Initialize(Environment* env, Local<Object> target) {
#undef V

#define V(name, key, __) \
auto IDX_STATE_SESSION_##name = OffsetOf(&Session::State::key);
auto IDX_STATE_SESSION_##name = offsetof(Session::State, key);
SESSION_STATE(V)
#undef V

Expand Down
11 changes: 6 additions & 5 deletions src/quic/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source {

// HTTP/3 specific options.
uint64_t max_field_section_size = 0;
size_t qpack_max_dtable_capacity = 0;
size_t qpack_encoder_max_dtable_capacity = 0;
size_t qpack_blocked_streams = 0;
uint64_t qpack_max_dtable_capacity = 0;
uint64_t qpack_encoder_max_dtable_capacity = 0;
uint64_t qpack_blocked_streams = 0;

SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(Application::Options)
Expand Down Expand Up @@ -225,11 +225,12 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source {
SET_MEMORY_INFO_NAME(Session)
SET_SELF_SIZE(Session)

struct State;
struct Stats;

private:
struct Impl;
struct MaybeCloseConnectionScope;
struct State;
struct Stats;

using StreamsMap = std::unordered_map<int64_t, BaseObjectPtr<Stream>>;
using QuicConnectionPointer = DeleteFnPtr<ngtcp2_conn, ngtcp2_conn_del>;
Expand Down
13 changes: 1 addition & 12 deletions src/quic/tlscontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <v8.h>
#include "bindingdata.h"
#include "defs.h"
#include "session.h"
#include "transportparams.h"

namespace node {
Expand All @@ -29,18 +30,6 @@ namespace quic {

const TLSContext::Options TLSContext::Options::kDefault = {};

// TODO(@jasnell): This session class is just a placeholder.
// The real session impl will be added in a separate commit.
class Session {
public:
operator ngtcp2_conn*() { return nullptr; }
void EmitKeylog(const char* line) const {}
void EmitSessionTicket(Store&& store) {}
void SetStreamOpenAllowed() {}
bool is_destroyed() const { return false; }
bool wants_session_ticket() const { return false; }
};

namespace {
constexpr size_t kMaxAlpnLen = 255;

Expand Down
2 changes: 2 additions & 0 deletions test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const { getSystemErrorName } = require('util');
delete providers.QUIC_PACKET;
delete providers.QUIC_UDP;
delete providers.QUIC_ENDPOINT;
delete providers.QUIC_SESSION;
delete providers.QUIC_STREAM;

const objKeys = Object.keys(providers);
if (objKeys.length > 0)
Expand Down

0 comments on commit a325de7

Please sign in to comment.