Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
e0118b4e
Unverified
Commit
e0118b4e
authored
Aug 26, 2018
by
Kenton Varda
Committed by
GitHub
Aug 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #732 from capnproto/todo-soons
Resolve or defer all TODO(soon)s
parents
a5e1d78f
ec9e6e05
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
42 additions
and
43 deletions
+42
-43
json-test.c++
c++/src/capnp/compat/json-test.c++
+3
-0
json-test.capnp
c++/src/capnp/compat/json-test.capnp
+0
-2
json.c++
c++/src/capnp/compat/json.c++
+9
-5
http-test.c++
c++/src/kj/compat/http-test.c++
+17
-9
http.c++
c++/src/kj/compat/http.c++
+2
-2
http.h
c++/src/kj/compat/http.h
+1
-15
tls.c++
c++/src/kj/compat/tls.c++
+1
-1
url.c++
c++/src/kj/compat/url.c++
+2
-2
debug.c++
c++/src/kj/debug.c++
+2
-2
filesystem-disk-test.c++
c++/src/kj/filesystem-disk-test.c++
+1
-1
filesystem-disk-win32.c++
c++/src/kj/filesystem-disk-win32.c++
+1
-1
mutex-test.c++
c++/src/kj/mutex-test.c++
+1
-1
mutex.h
c++/src/kj/mutex.h
+2
-2
No files found.
c++/src/capnp/compat/json-test.c++
View file @
e0118b4e
...
...
@@ -282,6 +282,9 @@ KJ_TEST("decode all types") {
CASE
(
R"({"structField":{"boolField":true}})"
,
root
.
getStructField
().
getBoolField
()
==
true
);
CASE
(
R"({"enumField":"bar"})"
,
root
.
getEnumField
()
==
TestEnum
::
BAR
);
CASE_NO_ROUNDTRIP
(
R"({"textField":"foo\u1234bar"})"
,
kj
::
str
(
"foo\u1234bar"
)
==
root
.
getTextField
());
CASE_THROW_RECOVERABLE
(
R"({"structField":null})"
,
"Expected object value"
);
CASE_THROW_RECOVERABLE
(
R"({"structList":null})"
,
"Expected list value"
);
CASE_THROW_RECOVERABLE
(
R"({"boolList":null})"
,
"Expected list value"
);
...
...
c++/src/capnp/compat/json-test.capnp
View file @
e0118b4e
...
...
@@ -114,5 +114,3 @@ enum TestJsonAnnotatedEnum {
baz @2 $Json.name("renamed-baz");
qux @3;
}
# TODO(now): enums
c++/src/capnp/compat/json.c++
View file @
e0118b4e
...
...
@@ -214,8 +214,8 @@ kj::String JsonCodec::encodeRaw(JsonValue::Reader value) const {
}
void
JsonCodec
::
encode
(
DynamicValue
::
Reader
input
,
Type
type
,
JsonValue
::
Builder
output
)
const
{
// TODO(so
on
): For interfaces, check for handlers on superclasses, per documentation...
// TODO(so
on
): For branded types, should we check for handlers on the generic?
// TODO(so
meday
): For interfaces, check for handlers on superclasses, per documentation...
// TODO(so
meday
): For branded types, should we check for handlers on the generic?
// TODO(someday): Allow registering handlers for "all structs", "all lists", etc?
KJ_IF_MAYBE
(
handler
,
impl
->
typeHandlers
.
find
(
type
))
{
(
*
handler
)
->
encodeBase
(
*
this
,
input
,
output
);
...
...
@@ -828,9 +828,13 @@ private:
}
}
// TODO(soon): Support at least basic multi-lingual plane, ie ignore surrogates.
KJ_REQUIRE
(
codePoint
<
128
,
"non-ASCII unicode escapes are not supported (yet!)"
);
target
.
add
(
0x7f
&
static_cast
<
char
>
(
codePoint
));
if
(
codePoint
<
128
)
{
target
.
add
(
0x7f
&
static_cast
<
char
>
(
codePoint
));
}
else
{
// TODO(perf): This is sorta malloc-heavy...
char16_t
u
=
codePoint
;
target
.
addAll
(
kj
::
decodeUtf16
(
kj
::
arrayPtr
(
&
u
,
1
)));
}
}
const
size_t
maxNestingDepth
;
...
...
c++/src/kj/compat/http-test.c++
View file @
e0118b4e
...
...
@@ -1910,8 +1910,10 @@ KJ_TEST("HttpClient WebSocket handshake") {
auto
headerTable
=
tableBuilder
.
build
();
FakeEntropySource
entropySource
;
HttpClientSettings
clientSettings
;
clientSettings
.
entropySource
=
entropySource
;
auto
client
=
newHttpClient
(
*
headerTable
,
*
pipe
.
ends
[
0
],
entropySource
);
auto
client
=
newHttpClient
(
*
headerTable
,
*
pipe
.
ends
[
0
],
clientSettings
);
testWebSocketClient
(
waitScope
,
*
headerTable
,
hMyHeader
,
*
client
);
...
...
@@ -1936,8 +1938,10 @@ KJ_TEST("HttpClient WebSocket error") {
auto
headerTable
=
tableBuilder
.
build
();
FakeEntropySource
entropySource
;
HttpClientSettings
clientSettings
;
clientSettings
.
entropySource
=
entropySource
;
auto
client
=
newHttpClient
(
*
headerTable
,
*
pipe
.
ends
[
0
],
entropySource
);
auto
client
=
newHttpClient
(
*
headerTable
,
*
pipe
.
ends
[
0
],
clientSettings
);
kj
::
HttpHeaders
headers
(
*
headerTable
);
headers
.
set
(
hMyHeader
,
"foo"
);
...
...
@@ -2455,7 +2459,9 @@ KJ_TEST("newHttpService from HttpClient WebSockets") {
{
HttpHeaderTable
table
;
FakeEntropySource
entropySource
;
auto
backClient
=
newHttpClient
(
table
,
*
backPipe
.
ends
[
0
],
entropySource
);
HttpClientSettings
clientSettings
;
clientSettings
.
entropySource
=
entropySource
;
auto
backClient
=
newHttpClient
(
table
,
*
backPipe
.
ends
[
0
],
clientSettings
);
auto
frontService
=
newHttpService
(
*
backClient
);
HttpServer
frontServer
(
timer
,
table
,
*
frontService
);
auto
listenTask
=
frontServer
.
listenHttp
(
kj
::
mv
(
frontPipe
.
ends
[
1
]));
...
...
@@ -2494,7 +2500,9 @@ KJ_TEST("newHttpService from HttpClient WebSockets disconnect") {
{
HttpHeaderTable
table
;
FakeEntropySource
entropySource
;
auto
backClient
=
newHttpClient
(
table
,
*
backPipe
.
ends
[
0
],
entropySource
);
HttpClientSettings
clientSettings
;
clientSettings
.
entropySource
=
entropySource
;
auto
backClient
=
newHttpClient
(
table
,
*
backPipe
.
ends
[
0
],
clientSettings
);
auto
frontService
=
newHttpService
(
*
backClient
);
HttpServer
frontServer
(
timer
,
table
,
*
frontService
);
auto
listenTask
=
frontServer
.
listenHttp
(
kj
::
mv
(
frontPipe
.
ends
[
1
]));
...
...
@@ -2801,11 +2809,11 @@ KJ_TEST("HttpClient connection management") {
KJ_EXPECT
(
count
==
0
);
#if __linux__
// TODO(so
on): Figure out why this doesn't work on Windows and is flakey on Mac. My guess is that
// th
e closing of the TCP connection propagates synchronously on Linux so that by the time w
e
//
poll() the EventPort it reports the client end of the connection has reached EOF, whereas on
//
Mac and Windows this propagation probably involves some concurrent process which may or may
// not complete before we poll(). A solution in this case would be to use a dummy in-memory
// TODO(so
meday): Figure out why this doesn't work on Windows and is flakey on Mac. My guess is
// th
at the closing of the TCP connection propagates synchronously on Linux so that by the tim
e
//
we poll() the EventPort it reports the client end of the connection has reached EOF, whereas
//
on Mac and Windows this propagation probably involves some concurrent process which may or
//
may
not complete before we poll(). A solution in this case would be to use a dummy in-memory
// ConnectionReceiver that returns in-memory pipes (see UnbufferedPipe earlier in this file),
// so that we don't rely on any non-local behavior. Another solution would be to pause for
// a short time, maybe.
...
...
c++/src/kj/compat/http.c++
View file @
e0118b4e
...
...
@@ -1570,7 +1570,7 @@ kj::Own<kj::AsyncInputStream> HttpInputStream::getEntityBody(
KJ_IF_MAYBE
(
te
,
headers
.
get
(
HttpHeaderId
::
TRANSFER_ENCODING
))
{
// TODO(someday): Support plugable transfer encodings? Or at least gzip?
// TODO(so
on
): Support stacked transfer encodings, e.g. "gzip, chunked".
// TODO(so
meday
): Support stacked transfer encodings, e.g. "gzip, chunked".
if
(
fastCaseCmp
<
'c'
,
'h'
,
'u'
,
'n'
,
'k'
,
'e'
,
'd'
>
(
te
->
cStr
()))
{
return
kj
::
heap
<
HttpChunkedEntityReader
>
(
*
this
);
}
else
{
...
...
@@ -1588,7 +1588,7 @@ kj::Own<kj::AsyncInputStream> HttpInputStream::getEntityBody(
}
KJ_IF_MAYBE
(
c
,
headers
.
get
(
HttpHeaderId
::
CONNECTION
))
{
// TODO(so
on
): Connection header can actually have multiple tokens... but no one ever uses
// TODO(so
meday
): Connection header can actually have multiple tokens... but no one ever uses
// that feature?
if
(
fastCaseCmp
<
'c'
,
'l'
,
'o'
,
's'
,
'e'
>
(
c
->
cStr
()))
{
return
kj
::
heap
<
HttpConnectionCloseEntityReader
>
(
*
this
);
...
...
c++/src/kj/compat/http.h
View file @
e0118b4e
...
...
@@ -152,7 +152,7 @@ public:
//
// HttpHeaderId::HOST
//
// TODO(so
on
): Fill this out with more common headers.
// TODO(so
meday
): Fill this out with more common headers.
#define DECLARE_HEADER(id, name) \
static const HttpHeaderId id;
...
...
@@ -637,12 +637,6 @@ kj::Own<HttpClient> newHttpClient(HttpHeaderTable& responseHeaderTable, kj::Asyn
// subsequent requests will fail. If a response takes a long time, it blocks subsequent responses.
// If a WebSocket is opened successfully, all subsequent requests fail.
kj
::
Own
<
HttpClient
>
newHttpClient
(
HttpHeaderTable
&
responseHeaderTable
,
kj
::
AsyncIoStream
&
stream
,
kj
::
Maybe
<
EntropySource
&>
entropySource
)
KJ_DEPRECATED
(
"use HttpClientSettings"
);
// Temporary for backwards-compatibilty.
// TODO(soon): Remove this before next release.
kj
::
Own
<
HttpClient
>
newHttpClient
(
HttpService
&
service
);
kj
::
Own
<
HttpService
>
newHttpService
(
HttpClient
&
client
);
// Adapts an HttpClient to an HttpService and vice versa.
...
...
@@ -802,12 +796,4 @@ inline void HttpHeaders::forEach(Func&& func) const {
}
}
inline
kj
::
Own
<
HttpClient
>
newHttpClient
(
HttpHeaderTable
&
responseHeaderTable
,
kj
::
AsyncIoStream
&
stream
,
kj
::
Maybe
<
EntropySource
&>
entropySource
)
{
HttpClientSettings
settings
;
settings
.
entropySource
=
entropySource
;
return
newHttpClient
(
responseHeaderTable
,
stream
,
kj
::
mv
(
settings
));
}
}
// namespace kj
c++/src/kj/compat/tls.c++
View file @
e0118b4e
...
...
@@ -183,7 +183,7 @@ public:
void
shutdownWrite
()
override
{
KJ_REQUIRE
(
shutdownTask
==
nullptr
,
"already called shutdownWrite()"
);
// TODO(
soon
): shutdownWrite() is problematic because it doesn't return a promise. It was
// TODO(
0.8
): shutdownWrite() is problematic because it doesn't return a promise. It was
// designed to assume that it would only be called after all writes are finished and that
// there was no reason to block at that point, but SSL sessions don't fit this since they
// actually have to send a shutdown message.
...
...
c++/src/kj/compat/url.c++
View file @
e0118b4e
...
...
@@ -72,8 +72,8 @@ constexpr auto NOT_SCHEME_CHARS = SCHEME_CHARS.invert();
constexpr
auto
HOST_CHARS
=
ALPHAS
.
orGroup
(
DIGITS
).
orAny
(
".-:[]_"
);
// [] is for ipv6 literals.
// _ is not allowed in domain names, but the WHATWG URL spec allows it in hostnames, so we do, too.
// TODO(so
on): The URL spec actually allows a lot more than just '_', and requires nameprepping to
// Punycode. We'll have to decide how we want to deal with all that.
// TODO(so
meday): The URL spec actually allows a lot more than just '_', and requires nameprepping
//
to
Punycode. We'll have to decide how we want to deal with all that.
void
toLower
(
String
&
text
)
{
for
(
char
&
c
:
text
)
{
...
...
c++/src/kj/debug.c++
View file @
e0118b4e
...
...
@@ -137,7 +137,7 @@ Exception::Type typeOfErrno(int error) {
Exception
::
Type
typeOfWin32Error
(
DWORD
error
)
{
switch
(
error
)
{
// TODO(so
on
): This needs more work.
// TODO(so
meday
): This needs more work.
case
WSAETIMEDOUT
:
return
Exception
::
Type
::
OVERLOADED
;
...
...
@@ -360,7 +360,7 @@ void Debug::Fault::init(
const
char
*
file
,
int
line
,
Win32Result
osErrorNumber
,
const
char
*
condition
,
const
char
*
macroArgs
,
ArrayPtr
<
String
>
argValues
)
{
LPVOID
ptr
;
// TODO(so
on
): Why doesn't this work for winsock errors?
// TODO(so
meday
): Why doesn't this work for winsock errors?
DWORD
result
=
FormatMessageW
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
...
...
c++/src/kj/filesystem-disk-test.c++
View file @
e0118b4e
...
...
@@ -729,7 +729,7 @@ KJ_TEST("DiskDirectory createTemporary") {
KJ_EXPECT
(
dir
->
listNames
()
==
nullptr
);
}
#if !__CYGWIN__ // TODO(so
on
): Figure out why this doesn't work on Cygwin.
#if !__CYGWIN__ // TODO(so
meday
): Figure out why this doesn't work on Cygwin.
KJ_TEST
(
"DiskDirectory replaceSubdir()"
)
{
TempDir
tempDir
;
auto
dir
=
tempDir
.
get
();
...
...
c++/src/kj/filesystem-disk-win32.c++
View file @
e0118b4e
...
...
@@ -1171,7 +1171,7 @@ public:
candidatePath
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
// TODO(so
on
): makeSecAttr(WriteMode::PRIVATE), when it's implemented
NULL
,
// TODO(so
meday
): makeSecAttr(WriteMode::PRIVATE), when it's implemented
CREATE_NEW
,
FILE_ATTRIBUTE_TEMPORARY
|
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
...
...
c++/src/kj/mutex-test.c++
View file @
e0118b4e
...
...
@@ -119,7 +119,7 @@ TEST(Mutex, MutexGuarded) {
EXPECT_EQ
(
321u
,
value
.
getWithoutLock
());
}
#if KJ_USE_FUTEX // TODO(so
on
): Implement on pthread & win32
#if KJ_USE_FUTEX // TODO(so
meday
): Implement on pthread & win32
TEST
(
Mutex
,
When
)
{
MutexGuarded
<
uint
>
value
(
123
);
...
...
c++/src/kj/mutex.h
View file @
e0118b4e
...
...
@@ -66,7 +66,7 @@ public:
// non-trivial, assert that the mutex is locked (which should be good enough to catch problems
// in unit tests). In non-debug builds, do nothing.
#if KJ_USE_FUTEX // TODO(so
on
): Implement on pthread & win32
#if KJ_USE_FUTEX // TODO(so
meday
): Implement on pthread & win32
class
Predicate
{
public
:
virtual
bool
check
()
=
0
;
...
...
@@ -263,7 +263,7 @@ public:
inline
T
&
getAlreadyLockedExclusive
()
const
;
// Like `getWithoutLock()`, but asserts that the lock is already held by the calling thread.
#if KJ_USE_FUTEX // TODO(so
on
): Implement on pthread & win32
#if KJ_USE_FUTEX // TODO(so
meday
): Implement on pthread & win32
template
<
typename
Cond
,
typename
Func
>
auto
when
(
Cond
&&
condition
,
Func
&&
callback
)
const
->
decltype
(
callback
(
instance
<
T
&>
()))
{
// Waits until condition(state) returns true, then calls callback(state) under lock.
...
...
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