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
eb7597fc
Commit
eb7597fc
authored
Jun 20, 2019
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sendStream() failing if it can't complete immediately.
parent
d8dd3233
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
async-io-test.c++
c++/src/kj/async-io-test.c++
+41
-0
async-io-unix.c++
c++/src/kj/async-io-unix.c++
+1
-1
No files found.
c++/src/kj/async-io-test.c++
View file @
eb7597fc
...
...
@@ -238,6 +238,47 @@ TEST(AsyncIo, CapabilityPipe) {
EXPECT_EQ
(
"foo"
,
result2
);
}
TEST
(
AsyncIo
,
CapabilityPipeBlockedSendStream
)
{
// Check for a bug that existed at one point where if a sendStream() call couldn't complete
// immediately, it would fail.
auto
io
=
setupAsyncIo
();
auto
pipe
=
io
.
provider
->
newCapabilityPipe
();
Promise
<
void
>
promise
=
nullptr
;
Own
<
AsyncIoStream
>
endpoint1
;
uint
nonBlockedCount
=
0
;
for
(;;)
{
auto
pipe2
=
io
.
provider
->
newCapabilityPipe
();
promise
=
pipe
.
ends
[
0
]
->
sendStream
(
kj
::
mv
(
pipe2
.
ends
[
0
]));
if
(
promise
.
poll
(
io
.
waitScope
))
{
// Send completed immediately, because there was enough space in the stream.
++
nonBlockedCount
;
promise
.
wait
(
io
.
waitScope
);
}
else
{
// Send blocked! Let's continue with this promise then!
endpoint1
=
kj
::
mv
(
pipe2
.
ends
[
1
]);
break
;
}
}
for
(
uint
i
KJ_UNUSED
:
kj
::
zeroTo
(
nonBlockedCount
))
{
// Receive and ignore all the streams that were sent without blocking.
pipe
.
ends
[
1
]
->
receiveStream
().
wait
(
io
.
waitScope
);
}
// Now that write that blocked should have been able to complete.
promise
.
wait
(
io
.
waitScope
);
// Now get the one that blocked.
auto
endpoint2
=
pipe
.
ends
[
1
]
->
receiveStream
().
wait
(
io
.
waitScope
);
endpoint1
->
write
(
"foo"
,
3
).
wait
(
io
.
waitScope
);
endpoint1
->
shutdownWrite
();
KJ_EXPECT
(
endpoint2
->
readAllText
().
wait
(
io
.
waitScope
)
==
"foo"
);
}
TEST
(
AsyncIo
,
CapabilityPipeMultiStreamMessage
)
{
auto
ioContext
=
setupAsyncIo
();
...
...
c++/src/kj/async-io-unix.c++
View file @
eb7597fc
...
...
@@ -216,7 +216,7 @@ public:
return
downcast
<
AsyncStreamFd
>
(
*
stream
).
fd
;
};
auto
promise
=
writeInternal
(
data
,
moreData
,
fds
);
return
promise
.
attach
(
kj
::
mv
(
fds
));
return
promise
.
attach
(
kj
::
mv
(
fds
)
,
kj
::
mv
(
streams
)
);
}
Promise
<
void
>
whenWriteDisconnected
()
override
{
...
...
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