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
540b1887
Commit
540b1887
authored
Nov 29, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use UnwindDetector to protect against exceptions in all these RPC object desturctors.
parent
2d1c9a53
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
rpc.c++
c++/src/capnp/rpc.c++
+15
-0
No files found.
c++/src/capnp/rpc.c++
View file @
540b1887
...
...
@@ -735,6 +735,7 @@ private:
:
RpcClient
(
connectionState
),
importId
(
importId
)
{}
~
ImportClient
()
noexcept
(
false
)
{
unwindDetector
.
catchExceptionsIfUnwinding
([
&
]()
{
// Remove self from the import table, if the table is still pointing at us. (It's possible
// that another thread attempted to obtain this import just as the destructor started, in
// which case that other thread will have constructed a new ImportClient and placed it in
...
...
@@ -757,6 +758,7 @@ private:
builder
.
setReferenceCount
(
remoteRefcount
);
message
->
send
();
}
});
}
void
addRemoteRef
()
{
...
...
@@ -794,6 +796,8 @@ private:
uint
remoteRefcount
=
0
;
// Number of times we've received this import from the peer.
kj
::
UnwindDetector
unwindDetector
;
};
class
PipelineClient
final
:
public
RpcClient
{
...
...
@@ -1372,6 +1376,7 @@ private:
CapInjectorImpl
(
RpcConnectionState
&
connectionState
)
:
connectionState
(
connectionState
)
{}
~
CapInjectorImpl
()
noexcept
(
false
)
{
unwindDetector
.
catchExceptionsIfUnwinding
([
&
]()
{
kj
::
Vector
<
kj
::
Own
<
ResolutionChain
>>
thingsToRelease
(
exports
.
size
());
if
(
connectionState
.
networkException
==
nullptr
)
{
...
...
@@ -1379,6 +1384,7 @@ private:
thingsToRelease
.
add
(
connectionState
.
releaseExport
(
exportId
,
1
));
}
}
});
}
bool
hasCaps
()
{
...
...
@@ -1451,6 +1457,8 @@ private:
kj
::
Vector
<
ExportId
>
exports
;
// IDs of objects exported during finishDescriptors(). These will need to be released later.
kj
::
UnwindDetector
unwindDetector
;
static
const
void
*
identity
(
const
rpc
::
CapDescriptor
::
Reader
&
desc
)
{
// TODO(cleanup): Don't rely on internal APIs here.
return
_
::
PointerHelpers
<
rpc
::
CapDescriptor
>::
getInternalReader
(
desc
).
getLocation
();
...
...
@@ -1471,6 +1479,7 @@ private:
:
connectionState
(
kj
::
addRef
(
connectionState
)),
id
(
id
),
fulfiller
(
kj
::
mv
(
fulfiller
))
{}
~
QuestionRef
()
{
unwindDetector
.
catchExceptionsIfUnwinding
([
&
]()
{
if
(
connectionState
->
networkException
!=
nullptr
)
{
return
;
}
...
...
@@ -1505,6 +1514,7 @@ private:
}
else
{
question
.
selfRef
=
nullptr
;
}
});
}
inline
QuestionId
getId
()
const
{
return
id
;
}
...
...
@@ -1533,6 +1543,7 @@ private:
QuestionId
id
;
kj
::
Own
<
kj
::
PromiseFulfiller
<
kj
::
Promise
<
kj
::
Own
<
RpcResponse
>>>>
fulfiller
;
kj
::
Maybe
<
kj
::
Own
<
CapExtractorImpl
>>
resultCaps
;
kj
::
UnwindDetector
unwindDetector
;
};
class
RpcRequest
final
:
public
RequestHook
{
...
...
@@ -2811,6 +2822,7 @@ public:
}
~
Impl
()
noexcept
(
false
)
{
unwindDetector
.
catchExceptionsIfUnwinding
([
&
]()
{
// std::unordered_map doesn't like it when elements' destructors throw, so carefully
// disassemble it.
if
(
!
connections
.
empty
())
{
...
...
@@ -2823,6 +2835,7 @@ public:
deleteMe
.
add
(
kj
::
mv
(
entry
.
second
));
}
}
});
}
Capability
::
Client
restore
(
_
::
StructReader
hostId
,
ObjectPointer
::
Reader
objectId
)
{
...
...
@@ -2850,6 +2863,8 @@ private:
ConnectionMap
;
ConnectionMap
connections
;
kj
::
UnwindDetector
unwindDetector
;
RpcConnectionState
&
getConnectionState
(
kj
::
Own
<
VatNetworkBase
::
Connection
>&&
connection
)
{
auto
iter
=
connections
.
find
(
connection
);
if
(
iter
==
connections
.
end
())
{
...
...
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