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
12d346b2
Unverified
Commit
12d346b2
authored
Nov 06, 2018
by
Kenton Varda
Committed by
GitHub
Nov 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #758 from capnproto/websocket-post-close
Allow WebSocket to keep sending after close().
parents
fc9a4e45
308e5cda
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
http.c++
c++/src/kj/compat/http.c++
+20
-18
No files found.
c++/src/kj/compat/http.c++
View file @
12d346b2
...
@@ -2003,23 +2003,21 @@ public:
...
@@ -2003,23 +2003,21 @@ public:
}
}
kj
::
Promise
<
void
>
disconnect
()
override
{
kj
::
Promise
<
void
>
disconnect
()
override
{
if
(
!
sendClosed
)
{
KJ_REQUIRE
(
!
currentlySending
,
"another message send is already in progress"
);
KJ_REQUIRE
(
!
currentlySending
,
"another message send is already in progress"
);
KJ_IF_MAYBE
(
p
,
sendingPong
)
{
// We recently sent a pong, make sure it's finished before proceeding.
currentlySending
=
true
;
auto
promise
=
p
->
then
([
this
]()
{
currentlySending
=
false
;
return
disconnect
();
});
sendingPong
=
nullptr
;
return
promise
;
}
sendClosed
=
true
;
KJ_IF_MAYBE
(
p
,
sendingPong
)
{
// We recently sent a pong, make sure it's finished before proceeding.
currentlySending
=
true
;
auto
promise
=
p
->
then
([
this
]()
{
currentlySending
=
false
;
return
disconnect
();
});
sendingPong
=
nullptr
;
return
promise
;
}
}
disconnected
=
true
;
stream
->
shutdownWrite
();
stream
->
shutdownWrite
();
return
kj
::
READY_NOW
;
return
kj
::
READY_NOW
;
}
}
...
@@ -2348,7 +2346,8 @@ private:
...
@@ -2348,7 +2346,8 @@ private:
kj
::
Own
<
kj
::
AsyncIoStream
>
stream
;
kj
::
Own
<
kj
::
AsyncIoStream
>
stream
;
kj
::
Maybe
<
EntropySource
&>
maskKeyGenerator
;
kj
::
Maybe
<
EntropySource
&>
maskKeyGenerator
;
bool
sendClosed
=
false
;
bool
hasSentClose
=
false
;
bool
disconnected
=
false
;
bool
currentlySending
=
false
;
bool
currentlySending
=
false
;
Header
sendHeader
;
Header
sendHeader
;
kj
::
ArrayPtr
<
const
byte
>
sendParts
[
2
];
kj
::
ArrayPtr
<
const
byte
>
sendParts
[
2
];
...
@@ -2375,7 +2374,7 @@ private:
...
@@ -2375,7 +2374,7 @@ private:
kj
::
ArrayPtr
<
byte
>
recvData
;
kj
::
ArrayPtr
<
byte
>
recvData
;
kj
::
Promise
<
void
>
sendImpl
(
byte
opcode
,
kj
::
ArrayPtr
<
const
byte
>
message
)
{
kj
::
Promise
<
void
>
sendImpl
(
byte
opcode
,
kj
::
ArrayPtr
<
const
byte
>
message
)
{
KJ_REQUIRE
(
!
sendClosed
,
"WebSocket already closed
"
);
KJ_REQUIRE
(
!
disconnected
,
"WebSocket can't send after disconnect()
"
);
KJ_REQUIRE
(
!
currentlySending
,
"another message send is already in progress"
);
KJ_REQUIRE
(
!
currentlySending
,
"another message send is already in progress"
);
currentlySending
=
true
;
currentlySending
=
true
;
...
@@ -2390,7 +2389,10 @@ private:
...
@@ -2390,7 +2389,10 @@ private:
return
promise
;
return
promise
;
}
}
sendClosed
=
opcode
==
OPCODE_CLOSE
;
// We don't stop the application from sending further messages after close() -- this is the
// application's error to make. But, we do want to make sure we don't send any PONGs after a
// close, since that would be our error. So we stack whether we closed for that reason.
hasSentClose
=
hasSentClose
||
opcode
==
OPCODE_CLOSE
;
Mask
mask
(
maskKeyGenerator
);
Mask
mask
(
maskKeyGenerator
);
...
@@ -2441,7 +2443,7 @@ private:
...
@@ -2441,7 +2443,7 @@ private:
}
}
kj
::
Promise
<
void
>
sendPong
(
kj
::
Array
<
byte
>
payload
)
{
kj
::
Promise
<
void
>
sendPong
(
kj
::
Array
<
byte
>
payload
)
{
if
(
sendClos
ed
)
{
if
(
hasSentClose
||
disconnect
ed
)
{
return
kj
::
READY_NOW
;
return
kj
::
READY_NOW
;
}
}
...
...
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