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
863f2977
Commit
863f2977
authored
Sep 12, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with new node_id serialization format
parent
46019288
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
18 deletions
+32
-18
libcaf_core/caf/detail/proper_actor.hpp
libcaf_core/caf/detail/proper_actor.hpp
+2
-0
libcaf_core/src/actor_namespace.cpp
libcaf_core/src/actor_namespace.cpp
+3
-3
libcaf_core/src/string_serialization.cpp
libcaf_core/src/string_serialization.cpp
+21
-7
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+2
-2
unit_testing/test_serialization.cpp
unit_testing/test_serialization.cpp
+4
-6
No files found.
libcaf_core/caf/detail/proper_actor.hpp
View file @
863f2977
...
...
@@ -56,9 +56,11 @@ class proper_actor_base : public Policies::resume_policy::template
message
msg
,
execution_unit
*
eu
)
override
{
CAF_PUSH_AID
(
dptr
()
->
id
());
/*
CAF_LOG_DEBUG(CAF_TARG(sender, to_string)
<< ", " << CAF_MARG(mid, integer_value) << ", "
<< CAF_TARG(msg, to_string));
*/
scheduling_policy
().
enqueue
(
dptr
(),
sender
,
mid
,
msg
,
eu
);
}
...
...
libcaf_core/src/actor_namespace.cpp
View file @
863f2977
...
...
@@ -46,8 +46,8 @@ void actor_namespace::write(serializer* sink, const actor_addr& addr) {
node_id
::
host_id_type
zero
;
std
::
fill
(
zero
.
begin
(),
zero
.
end
(),
0
);
sink
->
write_value
(
static_cast
<
actor_id
>
(
0
));
// actor id
sink
->
write_value
(
static_cast
<
uint32_t
>
(
0
));
// process id
sink
->
write_raw
(
node_id
::
host_id_size
,
zero
.
data
());
// host id
sink
->
write_value
(
static_cast
<
uint32_t
>
(
0
));
// process id
}
else
{
// register locally running actors to be able to deserialize them later
if
(
!
addr
.
is_remote
())
{
...
...
@@ -56,8 +56,8 @@ void actor_namespace::write(serializer* sink, const actor_addr& addr) {
}
auto
pinf
=
addr
.
node
();
sink
->
write_value
(
addr
.
id
());
// actor id
sink
->
write_value
(
pinf
.
process_id
());
// process id
sink
->
write_raw
(
node_id
::
host_id_size
,
pinf
.
host_id
().
data
());
// host id
sink
->
write_value
(
pinf
.
process_id
());
// process id
}
}
...
...
@@ -65,8 +65,8 @@ actor_addr actor_namespace::read(deserializer* source) {
CAF_REQUIRE
(
source
!=
nullptr
);
node_id
::
host_id_type
hid
;
auto
aid
=
source
->
read
<
uint32_t
>
();
// actor id
auto
pid
=
source
->
read
<
uint32_t
>
();
// process id
source
->
read_raw
(
node_id
::
host_id_size
,
hid
.
data
());
// host id
auto
pid
=
source
->
read
<
uint32_t
>
();
// process id
node_id
this_node
=
detail
::
singletons
::
get_node_id
();
if
(
aid
==
0
&&
pid
==
0
)
{
// 0:0 identifies an invalid actor
...
...
libcaf_core/src/string_serialization.cpp
View file @
863f2977
...
...
@@ -139,20 +139,26 @@ class string_serializer : public serializer, public dummy_backend {
out
(
mout
),
m_namespace
(
*
this
),
m_after_value
(
false
),
m_obj_just_opened
(
false
)
{}
m_obj_just_opened
(
false
)
{
// nop
}
void
begin_object
(
const
uniform_type_info
*
uti
)
{
clear
();
string
tname
=
uti
->
name
();
m_open_objects
.
push
(
tname
);
// do not print type names for strings and atoms
if
(
!
isbuiltin
(
tname
))
if
(
!
isbuiltin
(
tname
)
&&
tname
!=
"@message"
)
{
// suppress output of "@message ( ... )" because it's redundant
// since each message immediately calls begin_object(...)
// for the typed tuple it's containing
out
<<
tname
;
else
if
(
tname
.
compare
(
0
,
3
,
"@<>"
)
==
0
)
{
m_obj_just_opened
=
true
;
}
else
if
(
tname
.
compare
(
0
,
3
,
"@<>"
)
==
0
)
{
std
::
vector
<
string
>
subtypes
;
split
(
subtypes
,
tname
,
is_any_of
(
"+"
),
token_compress_on
);
m_obj_just_opened
=
true
;
}
m_obj_just_opened
=
true
;
}
void
end_object
()
{
...
...
@@ -162,7 +168,8 @@ class string_serializer : public serializer, public dummy_backend {
}
m_after_value
=
true
;
if
(
!
m_open_objects
.
empty
())
{
if
(
!
isbuiltin
(
m_open_objects
.
top
()))
{
auto
&
open_obj
=
m_open_objects
.
top
();
if
(
!
isbuiltin
(
open_obj
)
&&
open_obj
!=
"@message"
)
{
out
<<
(
m_after_value
?
" )"
:
")"
);
}
m_open_objects
.
pop
();
...
...
@@ -318,6 +325,12 @@ class string_deserializer : public deserializer, public dummy_backend {
void
read_value
(
primitive_variant
&
storage
)
override
{
integrity_check
();
skip_space_and_comma
();
if
(
m_open_objects
.
top
()
==
"@node"
)
{
// example node_id: c5c978f5bc5c7e4975e407bb03c751c9374480d9:63768
// deserialization will call read_raw() followed by read_value()
// and ':' must be ignored
consume
(
':'
);
}
string
::
iterator
substr_end
;
auto
find_if_cond
=
[](
char
c
)
->
bool
{
switch
(
c
)
{
...
...
@@ -402,8 +415,9 @@ class string_deserializer : public deserializer, public dummy_backend {
void
read_raw
(
size_t
buf_size
,
void
*
vbuf
)
override
{
if
(
buf_size
==
node_id
::
host_id_size
&&
!
m_open_objects
.
empty
()
&&
m_open_objects
.
top
()
==
"@node"
)
{
// node ids are formatted as process_id@host_id
&&
(
m_open_objects
.
top
()
==
"@actor"
||
m_open_objects
.
top
()
==
"@actor_addr"
))
{
// actor addresses are formatted as actor_id@host_id:process_id
// this read_raw reads the host_id, i.e., we need
// to skip the '@' character
consume
(
'@'
);
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
863f2977
...
...
@@ -339,14 +339,14 @@ void deserialize_impl(message& atref, deserializer* source) {
}
void
serialize_impl
(
const
node_id
&
nid
,
serializer
*
sink
)
{
sink
->
write_value
(
nid
.
process_id
());
sink
->
write_raw
(
nid
.
host_id
().
size
(),
nid
.
host_id
().
data
());
sink
->
write_value
(
nid
.
process_id
());
}
void
deserialize_impl
(
node_id
&
nid
,
deserializer
*
source
)
{
node_id
::
host_id_type
hid
;
auto
pid
=
source
->
read
<
uint32_t
>
();
source
->
read_raw
(
node_id
::
host_id_size
,
hid
.
data
());
auto
pid
=
source
->
read
<
uint32_t
>
();
auto
is_zero
=
[](
uint8_t
value
)
{
return
value
==
0
;
};
if
(
pid
==
0
&&
std
::
all_of
(
hid
.
begin
(),
hid
.
end
(),
is_zero
))
{
// invalid process information
...
...
unit_testing/test_serialization.cpp
View file @
863f2977
...
...
@@ -53,14 +53,12 @@ namespace {
struct
struct_a
{
int
x
;
int
y
;
};
struct
struct_b
{
struct_a
a
;
int
z
;
list
<
int
>
ints
;
};
using
strmap
=
map
<
string
,
u16string
>
;
...
...
@@ -68,12 +66,10 @@ using strmap = map<string, u16string>;
struct
struct_c
{
strmap
strings
;
set
<
int
>
ints
;
};
struct
raw_struct
{
string
str
;
};
bool
operator
==
(
const
raw_struct
&
lhs
,
const
raw_struct
&
rhs
)
{
...
...
@@ -118,7 +114,6 @@ enum class test_enum {
a
,
b
,
c
};
}
// namespace <anonymous>
...
...
@@ -145,7 +140,10 @@ int main() {
auto
nid_str
=
to_string
(
nid
);
CAF_PRINT
(
"nid_str = "
<<
nid_str
);
auto
nid2
=
from_string
<
node_id
>
(
nid_str
);
CAF_CHECK
(
nid2
&&
nid
==
*
nid2
);
CAF_CHECK
(
nid2
);
if
(
nid2
)
{
CAF_CHECK_EQUAL
(
to_string
(
nid
),
to_string
(
*
nid2
));
}
/*
auto oarr = new detail::object_array;
...
...
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