Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
67afbbba
Commit
67afbbba
authored
Sep 05, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Use ngtcp2_cid as a hash key
parent
b743ee21
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
22 deletions
+35
-22
src/shrpx_quic.cc
src/shrpx_quic.cc
+4
-0
src/shrpx_quic.h
src/shrpx_quic.h
+22
-0
src/shrpx_quic_connection_handler.cc
src/shrpx_quic_connection_handler.cc
+6
-20
src/shrpx_quic_connection_handler.h
src/shrpx_quic_connection_handler.h
+3
-2
No files found.
src/shrpx_quic.cc
View file @
67afbbba
...
...
@@ -45,6 +45,10 @@
using
namespace
nghttp2
;
bool
operator
==
(
const
ngtcp2_cid
&
lhs
,
const
ngtcp2_cid
&
rhs
)
{
return
ngtcp2_cid_eq
(
&
lhs
,
&
rhs
);
}
namespace
shrpx
{
ngtcp2_tstamp
quic_timestamp
()
{
...
...
src/shrpx_quic.h
View file @
67afbbba
...
...
@@ -29,8 +29,30 @@
#include <stdint.h>
#include <functional>
#include <ngtcp2/ngtcp2.h>
namespace
std
{
template
<
>
struct
hash
<
ngtcp2_cid
>
{
std
::
size_t
operator
()(
const
ngtcp2_cid
&
cid
)
const
noexcept
{
// FNV-1a 64bits variant
constexpr
uint64_t
basis
=
0xCBF29CE484222325ULL
;
const
uint8_t
*
p
=
cid
.
data
,
*
end
=
cid
.
data
+
cid
.
datalen
;
uint64_t
h
=
basis
;
for
(;
p
!=
end
;)
{
h
^=
*
p
++
;
h
*=
basis
;
}
return
static_cast
<
size_t
>
(
h
);
}
};
}
// namespace std
bool
operator
==
(
const
ngtcp2_cid
&
lhs
,
const
ngtcp2_cid
&
rhs
);
namespace
shrpx
{
struct
UpstreamAddr
;
...
...
src/shrpx_quic_connection_handler.cc
View file @
67afbbba
...
...
@@ -32,7 +32,6 @@
#include "shrpx_worker.h"
#include "shrpx_client_handler.h"
#include "shrpx_log.h"
#include "shrpx_quic.h"
#include "shrpx_http3_upstream.h"
#include "shrpx_connection_handler.h"
...
...
@@ -43,18 +42,6 @@ QUICConnectionHandler::QUICConnectionHandler(Worker *worker)
QUICConnectionHandler
::~
QUICConnectionHandler
()
{}
namespace
{
std
::
string
make_cid_key
(
const
uint8_t
*
dcid
,
size_t
dcidlen
)
{
return
std
::
string
{
dcid
,
dcid
+
dcidlen
};
}
}
// namespace
namespace
{
std
::
string
make_cid_key
(
const
ngtcp2_cid
*
cid
)
{
return
make_cid_key
(
cid
->
data
,
cid
->
datalen
);
}
}
// namespace
int
QUICConnectionHandler
::
handle_packet
(
const
UpstreamAddr
*
faddr
,
const
Address
&
remote_addr
,
const
Address
&
local_addr
,
...
...
@@ -80,7 +67,8 @@ int QUICConnectionHandler::handle_packet(const UpstreamAddr *faddr,
auto
config
=
get_config
();
auto
dcid_key
=
make_cid_key
(
dcid
,
dcidlen
);
ngtcp2_cid
dcid_key
;
ngtcp2_cid_init
(
&
dcid_key
,
dcid
,
dcidlen
);
auto
conn_handler
=
worker_
->
get_connection_handler
();
...
...
@@ -462,24 +450,22 @@ int QUICConnectionHandler::send_connection_close(
void
QUICConnectionHandler
::
add_connection_id
(
const
ngtcp2_cid
*
cid
,
ClientHandler
*
handler
)
{
auto
key
=
make_cid_key
(
cid
);
connections_
.
emplace
(
key
,
handler
);
connections_
.
emplace
(
*
cid
,
handler
);
}
void
QUICConnectionHandler
::
remove_connection_id
(
const
ngtcp2_cid
*
cid
)
{
auto
key
=
make_cid_key
(
cid
);
connections_
.
erase
(
key
);
connections_
.
erase
(
*
cid
);
}
void
QUICConnectionHandler
::
add_close_wait
(
CloseWait
*
cw
)
{
for
(
auto
&
cid
:
cw
->
scids
)
{
close_waits_
.
emplace
(
make_cid_key
(
&
cid
)
,
cw
);
close_waits_
.
emplace
(
cid
,
cw
);
}
}
void
QUICConnectionHandler
::
remove_close_wait
(
const
CloseWait
*
cw
)
{
for
(
auto
&
cid
:
cw
->
scids
)
{
close_waits_
.
erase
(
make_cid_key
(
&
cid
)
);
close_waits_
.
erase
(
cid
);
}
}
...
...
src/shrpx_quic_connection_handler.h
View file @
67afbbba
...
...
@@ -36,6 +36,7 @@
#include <ev.h>
#include "shrpx_quic.h"
#include "network.h"
using
namespace
nghttp2
;
...
...
@@ -127,8 +128,8 @@ public:
private:
Worker
*
worker_
;
std
::
unordered_map
<
std
::
string
,
ClientHandler
*>
connections_
;
std
::
unordered_map
<
std
::
string
,
CloseWait
*>
close_waits_
;
std
::
unordered_map
<
ngtcp2_cid
,
ClientHandler
*>
connections_
;
std
::
unordered_map
<
ngtcp2_cid
,
CloseWait
*>
close_waits_
;
};
}
// namespace shrpx
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment