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
dde41c25
Commit
dde41c25
authored
Jan 14, 2021
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align port and addr functions in network managers
parent
845b9831
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
40 deletions
+53
-40
libcaf_io/caf/io/abstract_broker.hpp
libcaf_io/caf/io/abstract_broker.hpp
+17
-13
libcaf_io/caf/io/datagram_servant.hpp
libcaf_io/caf/io/datagram_servant.hpp
+1
-1
libcaf_io/caf/io/network/acceptor_manager.hpp
libcaf_io/caf/io/network/acceptor_manager.hpp
+3
-1
libcaf_io/caf/io/network/datagram_manager.hpp
libcaf_io/caf/io/network/datagram_manager.hpp
+8
-4
libcaf_io/caf/io/network/datagram_servant_impl.hpp
libcaf_io/caf/io/network/datagram_servant_impl.hpp
+2
-2
libcaf_io/caf/io/network/manager.hpp
libcaf_io/caf/io/network/manager.hpp
+1
-5
libcaf_io/caf/io/network/stream_manager.hpp
libcaf_io/caf/io/network/stream_manager.hpp
+5
-2
libcaf_io/src/io/abstract_broker.cpp
libcaf_io/src/io/abstract_broker.cpp
+6
-2
libcaf_io/src/io/network/datagram_servant_impl.cpp
libcaf_io/src/io/network/datagram_servant_impl.cpp
+8
-8
libcaf_io/src/io/network/test_multiplexer.cpp
libcaf_io/src/io/network/test_multiplexer.cpp
+2
-2
No files found.
libcaf_io/caf/io/abstract_broker.hpp
View file @
dde41c25
...
@@ -18,24 +18,24 @@
...
@@ -18,24 +18,24 @@
#pragma once
#pragma once
#include <vector>
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include "caf/scheduled_actor.hpp"
#include "caf/prohibit_top_level_spawn_marker.hpp"
#include "caf/prohibit_top_level_spawn_marker.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/
receive_policy
.hpp"
#include "caf/io/
connection_handle
.hpp"
#include "caf/io/datagram_handle.hpp"
#include "caf/io/datagram_handle.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/receive_policy.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/connection_handle.hpp"
#include "caf/io/network/acceptor_manager.hpp"
#include "caf/io/network/datagram_manager.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/io/network/stream_manager.hpp"
#include "caf/io/network/stream_manager.hpp"
#include "caf/io/network/acceptor_manager.hpp"
#include "caf/io/network/datagram_manager.hpp"
namespace
caf
{
namespace
caf
{
namespace
io
{
namespace
io
{
...
@@ -223,10 +223,11 @@ public:
...
@@ -223,10 +223,11 @@ public:
add_datagram_servant_for_endpoint
(
network
::
native_socket
fd
,
add_datagram_servant_for_endpoint
(
network
::
native_socket
fd
,
const
network
::
ip_endpoint
&
ep
);
const
network
::
ip_endpoint
&
ep
);
/// Creates a new `datagram_servant` for the remote endpoint `host` and `port`.
/// Creates a new `datagram_servant` for the remote endpoint `host` and
/// `port`.
/// @returns The handle to the new `datagram_servant`.
/// @returns The handle to the new `datagram_servant`.
expected
<
datagram_handle
>
expected
<
datagram_handle
>
add_udp_datagram_servant
(
const
std
::
string
&
host
,
add_udp_datagram_servant
(
const
std
::
string
&
host
,
uint16_t
port
);
uint16_t
port
);
/// Tries to open a local port and creates a `datagram_servant` managing it on
/// Tries to open a local port and creates a `datagram_servant` managing it on
/// success. If `port == 0`, then the broker will ask the operating system to
/// success. If `port == 0`, then the broker will ask the operating system to
...
@@ -265,6 +266,10 @@ public:
...
@@ -265,6 +266,10 @@ public:
/// or an empty string if `hdl` is invalid.
/// or an empty string if `hdl` is invalid.
std
::
string
remote_addr
(
datagram_handle
hdl
);
std
::
string
remote_addr
(
datagram_handle
hdl
);
/// Returns the local address associated with `hdl`
/// or empty string if `hdl` is invalid.
std
::
string
local_addr
(
datagram_handle
hdl
);
/// Returns the remote port associated with `hdl`
/// Returns the remote port associated with `hdl`
/// or `0` if `hdl` is invalid.
/// or `0` if `hdl` is invalid.
uint16_t
remote_port
(
datagram_handle
hdl
);
uint16_t
remote_port
(
datagram_handle
hdl
);
...
@@ -358,8 +363,8 @@ protected:
...
@@ -358,8 +363,8 @@ protected:
using
doorman_map
=
std
::
unordered_map
<
accept_handle
,
intrusive_ptr
<
doorman
>>
;
using
doorman_map
=
std
::
unordered_map
<
accept_handle
,
intrusive_ptr
<
doorman
>>
;
using
scribe_map
=
std
::
unordered_map
<
connection_handle
,
using
scribe_map
intrusive_ptr
<
scribe
>>
;
=
std
::
unordered_map
<
connection_handle
,
intrusive_ptr
<
scribe
>>
;
using
datagram_servant_map
using
datagram_servant_map
=
std
::
unordered_map
<
datagram_handle
,
intrusive_ptr
<
datagram_servant
>>
;
=
std
::
unordered_map
<
datagram_handle
,
intrusive_ptr
<
datagram_servant
>>
;
...
@@ -428,4 +433,3 @@ private:
...
@@ -428,4 +433,3 @@ private:
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
libcaf_io/caf/io/datagram_servant.hpp
View file @
dde41c25
...
@@ -63,7 +63,7 @@ public:
...
@@ -63,7 +63,7 @@ public:
virtual
uint16_t
local_port
()
const
=
0
;
virtual
uint16_t
local_port
()
const
=
0
;
/// Returns the address of the remote endpoint for the handle.
/// Returns the address of the remote endpoint for the handle.
virtual
std
::
string
remote_addr
(
datagram_handle
)
const
=
0
;
virtual
std
::
string
local_addr
(
)
const
=
0
;
/// Returns all the handles associated with this servant
/// Returns all the handles associated with this servant
virtual
std
::
vector
<
datagram_handle
>
hdls
()
const
=
0
;
virtual
std
::
vector
<
datagram_handle
>
hdls
()
const
=
0
;
...
...
libcaf_io/caf/io/network/acceptor_manager.hpp
View file @
dde41c25
...
@@ -38,9 +38,11 @@ public:
...
@@ -38,9 +38,11 @@ public:
/// Get the port of the underlying I/O device.
/// Get the port of the underlying I/O device.
virtual
uint16_t
port
()
const
=
0
;
virtual
uint16_t
port
()
const
=
0
;
/// Get the address of the underlying I/O device.
virtual
std
::
string
addr
()
const
=
0
;
};
};
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
libcaf_io/caf/io/network/datagram_manager.hpp
View file @
dde41c25
...
@@ -34,12 +34,14 @@ public:
...
@@ -34,12 +34,14 @@ public:
/// Called by the underlying I/O device whenever it received data.
/// Called by the underlying I/O device whenever it received data.
/// @returns `true` if the manager accepts further reads, otherwise `false`.
/// @returns `true` if the manager accepts further reads, otherwise `false`.
virtual
bool
consume
(
execution_unit
*
,
datagram_handle
hdl
,
virtual
bool
receive_buffer
&
buf
)
=
0
;
consume
(
execution_unit
*
,
datagram_handle
hdl
,
receive_buffer
&
buf
)
=
0
;
/// Called by the underlying I/O device whenever it sent data.
/// Called by the underlying I/O device whenever it sent data.
virtual
void
datagram_sent
(
execution_unit
*
,
datagram_handle
hdl
,
size_t
,
virtual
void
datagram_sent
(
execution_unit
*
,
datagram_handle
hdl
,
size_t
,
std
::
vector
<
char
>
buffer
)
=
0
;
std
::
vector
<
char
>
buffer
)
=
0
;
/// Called by the underlying I/O device to indicate that a new remote
/// Called by the underlying I/O device to indicate that a new remote
/// endpoint has been detected, passing in the received datagram.
/// endpoint has been detected, passing in the received datagram.
...
@@ -49,9 +51,11 @@ public:
...
@@ -49,9 +51,11 @@ public:
/// Get the port of the underlying I/O device.
/// Get the port of the underlying I/O device.
virtual
uint16_t
port
(
datagram_handle
)
const
=
0
;
virtual
uint16_t
port
(
datagram_handle
)
const
=
0
;
/// Get the port of the underlying I/O device.
virtual
std
::
string
addr
(
datagram_handle
)
const
=
0
;
};
};
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
libcaf_io/caf/io/network/datagram_servant_impl.hpp
View file @
dde41c25
...
@@ -52,9 +52,9 @@ public:
...
@@ -52,9 +52,9 @@ public:
void
flush
()
override
;
void
flush
()
override
;
std
::
string
remote_
addr
(
datagram_handle
hdl
)
const
override
;
std
::
string
addr
(
datagram_handle
hdl
)
const
override
;
std
::
string
addr
()
const
override
;
std
::
string
local_
addr
()
const
override
;
uint16_t
port
(
datagram_handle
hdl
)
const
override
;
uint16_t
port
(
datagram_handle
hdl
)
const
override
;
...
...
libcaf_io/caf/io/network/manager.hpp
View file @
dde41c25
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
#pragma once
#pragma once
#include "caf/intrusive_ptr.hpp"
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/ref_counted.hpp"
#include "caf/ref_counted.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/network/operation.hpp"
#include "caf/io/network/operation.hpp"
...
@@ -65,9 +65,6 @@ public:
...
@@ -65,9 +65,6 @@ public:
/// Detaches this manager from its parent in case of an error.
/// Detaches this manager from its parent in case of an error.
void
io_failure
(
execution_unit
*
ctx
,
operation
op
);
void
io_failure
(
execution_unit
*
ctx
,
operation
op
);
/// Get the address of the underlying I/O device.
virtual
std
::
string
addr
()
const
=
0
;
protected:
protected:
/// Creates a message signalizing a disconnect to the parent.
/// Creates a message signalizing a disconnect to the parent.
virtual
message
detach_message
()
=
0
;
virtual
message
detach_message
()
=
0
;
...
@@ -81,4 +78,3 @@ protected:
...
@@ -81,4 +78,3 @@ protected:
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
libcaf_io/caf/io/network/stream_manager.hpp
View file @
dde41c25
...
@@ -38,13 +38,16 @@ public:
...
@@ -38,13 +38,16 @@ public:
/// Called by the underlying I/O device whenever it sent data.
/// Called by the underlying I/O device whenever it sent data.
virtual
void
data_transferred
(
execution_unit
*
ctx
,
size_t
num_bytes
,
virtual
void
data_transferred
(
execution_unit
*
ctx
,
size_t
num_bytes
,
size_t
remaining_bytes
)
=
0
;
size_t
remaining_bytes
)
=
0
;
/// Get the port of the underlying I/O device.
/// Get the port of the underlying I/O device.
virtual
uint16_t
port
()
const
=
0
;
virtual
uint16_t
port
()
const
=
0
;
/// Get the address of the underlying I/O device.
virtual
std
::
string
addr
()
const
=
0
;
};
};
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
libcaf_io/src/io/abstract_broker.cpp
View file @
dde41c25
...
@@ -320,8 +320,12 @@ datagram_handle abstract_broker::datagram_hdl_by_port(uint16_t port) {
...
@@ -320,8 +320,12 @@ datagram_handle abstract_broker::datagram_hdl_by_port(uint16_t port) {
std
::
string
abstract_broker
::
remote_addr
(
datagram_handle
hdl
)
{
std
::
string
abstract_broker
::
remote_addr
(
datagram_handle
hdl
)
{
auto
i
=
datagram_servants_
.
find
(
hdl
);
auto
i
=
datagram_servants_
.
find
(
hdl
);
return
i
!=
datagram_servants_
.
end
()
?
i
->
second
->
remote_addr
(
hdl
)
return
i
!=
datagram_servants_
.
end
()
?
i
->
second
->
addr
(
hdl
)
:
std
::
string
{};
:
std
::
string
{};
}
std
::
string
abstract_broker
::
local_addr
(
datagram_handle
hdl
)
{
auto
i
=
datagram_servants_
.
find
(
hdl
);
return
i
!=
datagram_servants_
.
end
()
?
i
->
second
->
local_addr
()
:
0
;
}
}
uint16_t
abstract_broker
::
remote_port
(
datagram_handle
hdl
)
{
uint16_t
abstract_broker
::
remote_port
(
datagram_handle
hdl
)
{
...
...
libcaf_io/src/io/network/datagram_servant_impl.cpp
View file @
dde41c25
...
@@ -87,14 +87,7 @@ void datagram_servant_impl::flush() {
...
@@ -87,14 +87,7 @@ void datagram_servant_impl::flush() {
handler_
.
flush
(
this
);
handler_
.
flush
(
this
);
}
}
std
::
string
datagram_servant_impl
::
addr
()
const
{
std
::
string
datagram_servant_impl
::
addr
(
datagram_handle
hdl
)
const
{
auto
x
=
remote_addr_of_fd
(
handler_
.
fd
());
if
(
!
x
)
return
""
;
return
*
x
;
}
std
::
string
datagram_servant_impl
::
remote_addr
(
datagram_handle
hdl
)
const
{
auto
&
eps
=
handler_
.
endpoints
();
auto
&
eps
=
handler_
.
endpoints
();
auto
itr
=
eps
.
find
(
hdl
);
auto
itr
=
eps
.
find
(
hdl
);
if
(
itr
==
eps
.
end
())
if
(
itr
==
eps
.
end
())
...
@@ -102,6 +95,13 @@ std::string datagram_servant_impl::remote_addr(datagram_handle hdl) const {
...
@@ -102,6 +95,13 @@ std::string datagram_servant_impl::remote_addr(datagram_handle hdl) const {
return
network
::
host
(
itr
->
second
);
return
network
::
host
(
itr
->
second
);
}
}
std
::
string
datagram_servant_impl
::
local_addr
()
const
{
auto
x
=
local_addr_of_fd
(
handler_
.
fd
());
if
(
!
x
)
return
0
;
return
*
x
;
}
uint16_t
datagram_servant_impl
::
port
(
datagram_handle
hdl
)
const
{
uint16_t
datagram_servant_impl
::
port
(
datagram_handle
hdl
)
const
{
auto
&
eps
=
handler_
.
endpoints
();
auto
&
eps
=
handler_
.
endpoints
();
auto
itr
=
eps
.
find
(
hdl
);
auto
itr
=
eps
.
find
(
hdl
);
...
...
libcaf_io/src/io/network/test_multiplexer.cpp
View file @
dde41c25
...
@@ -373,10 +373,10 @@ datagram_servant_ptr test_multiplexer::new_datagram_servant(datagram_handle hdl,
...
@@ -373,10 +373,10 @@ datagram_servant_ptr test_multiplexer::new_datagram_servant(datagram_handle hdl,
void
flush
()
override
{
void
flush
()
override
{
// nop
// nop
}
}
std
::
string
remote_
addr
(
datagram_handle
)
const
override
{
std
::
string
addr
(
datagram_handle
)
const
override
{
return
"test"
;
return
"test"
;
}
}
std
::
string
addr
()
const
override
{
std
::
string
local_
addr
()
const
override
{
return
"test"
;
return
"test"
;
}
}
uint16_t
port
(
datagram_handle
dh
)
const
override
{
uint16_t
port
(
datagram_handle
dh
)
const
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