Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
4c03f462
Commit
4c03f462
authored
Nov 21, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UB in datagram brokers, close #1174
parent
fb8551ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
23 deletions
+19
-23
libcaf_io/src/io/abstract_broker.cpp
libcaf_io/src/io/abstract_broker.cpp
+19
-23
No files found.
libcaf_io/src/io/abstract_broker.cpp
View file @
4c03f462
...
...
@@ -75,27 +75,25 @@ abstract_broker::~abstract_broker() {
void
abstract_broker
::
configure_read
(
connection_handle
hdl
,
receive_policy
::
config
cfg
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
)
<<
CAF_ARG
(
cfg
));
auto
x
=
by_id
(
hdl
);
if
(
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
configure_read
(
cfg
);
}
void
abstract_broker
::
ack_writes
(
connection_handle
hdl
,
bool
enable
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
)
<<
CAF_ARG
(
enable
));
auto
x
=
by_id
(
hdl
);
if
(
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
ack_writes
(
enable
);
}
byte_buffer
&
abstract_broker
::
wr_buf
(
connection_handle
hdl
)
{
CAF_ASSERT
(
hdl
!=
invalid_connection_handle
);
auto
x
=
by_id
(
hdl
);
if
(
!
x
)
{
if
(
auto
x
=
by_id
(
hdl
))
{
return
x
->
wr_buf
();
}
else
{
CAF_LOG_ERROR
(
"tried to access wr_buf() of an unknown connection_handle:"
<<
CAF_ARG
(
hdl
));
return
dummy_wr_buf_
;
}
return
x
->
wr_buf
();
}
void
abstract_broker
::
write
(
connection_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
...
...
@@ -110,34 +108,32 @@ void abstract_broker::write(connection_handle hdl, span<const byte> buf) {
}
void
abstract_broker
::
flush
(
connection_handle
hdl
)
{
auto
x
=
by_id
(
hdl
);
if
(
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
flush
();
}
void
abstract_broker
::
ack_writes
(
datagram_handle
hdl
,
bool
enable
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
)
<<
CAF_ARG
(
enable
));
auto
x
=
by_id
(
hdl
);
if
(
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
ack_writes
(
enable
);
}
byte_buffer
&
abstract_broker
::
wr_buf
(
datagram_handle
hdl
)
{
auto
x
=
by_id
(
hdl
);
if
(
!
x
)
{
if
(
auto
x
=
by_id
(
hdl
))
{
return
x
->
wr_buf
(
hdl
);
}
else
{
CAF_LOG_ERROR
(
"tried to access wr_buf() of an unknown"
"datagram_handle"
);
return
dummy_wr_buf_
;
}
return
x
->
wr_buf
(
hdl
);
}
void
abstract_broker
::
enqueue_datagram
(
datagram_handle
hdl
,
byte_buffer
buf
)
{
auto
x
=
by_id
(
hdl
);
if
(
!
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
enqueue_datagram
(
hdl
,
std
::
move
(
buf
));
else
CAF_LOG_ERROR
(
"tried to access datagram_buffer() of an unknown"
"datagram_handle"
);
x
->
enqueue_datagram
(
hdl
,
std
::
move
(
buf
));
}
void
abstract_broker
::
write
(
datagram_handle
hdl
,
size_t
bs
,
const
void
*
buf
)
{
...
...
@@ -148,8 +144,7 @@ void abstract_broker::write(datagram_handle hdl, size_t bs, const void* buf) {
}
void
abstract_broker
::
flush
(
datagram_handle
hdl
)
{
auto
x
=
by_id
(
hdl
);
if
(
x
)
if
(
auto
x
=
by_id
(
hdl
))
x
->
flush
();
}
...
...
@@ -337,11 +332,12 @@ uint16_t abstract_broker::local_port(datagram_handle hdl) {
}
bool
abstract_broker
::
remove_endpoint
(
datagram_handle
hdl
)
{
auto
x
=
by_id
(
hdl
);
if
(
!
x
)
if
(
auto
x
=
by_id
(
hdl
))
{
x
->
remove_endpoint
(
hdl
);
return
true
;
}
else
{
return
false
;
x
->
remove_endpoint
(
hdl
);
return
true
;
}
}
void
abstract_broker
::
close_all
()
{
...
...
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