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
3132985f
Commit
3132985f
authored
Apr 25, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use buffers
parent
c390beaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
src/post_office.cpp
src/post_office.cpp
+24
-20
No files found.
src/post_office.cpp
View file @
3132985f
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
<< cppa::process_information::get()->process_id() \
<< cppa::process_information::get()->process_id() \
<< "] " << arg << std::endl
<< "] " << arg << std::endl
#undef DEBUG
//
#undef DEBUG
#define DEBUG(unused) ((void) 0)
//
#define DEBUG(unused) ((void) 0)
using
std
::
cout
;
using
std
::
cout
;
using
std
::
cerr
;
using
std
::
cerr
;
...
@@ -176,18 +176,28 @@ class po_peer
...
@@ -176,18 +176,28 @@ class po_peer
send2po
(
atom
(
"RM_PEER"
),
m_socket
);
send2po
(
atom
(
"RM_PEER"
),
m_socket
);
});
});
DEBUG
(
"po_peer loop started"
);
DEBUG
(
"po_peer loop started"
);
std
::
uint32_t
msg_size
;
buffer
<
512
,
(
16
*
1024
*
1024
)
>
m_buf
;
std
::
vector
<
char
>
msg_buf
;
m_buf
.
reset
(
m_state
==
wait_for_process_info
?
sizeof
(
std
::
uint32_t
)
+
process_information
::
node_id_size
:
sizeof
(
std
::
uint32_t
));
for
(;;)
for
(;;)
{
{
while
(
m_buf
.
ready
()
==
false
)
{
if
(
m_buf
.
append_from
(
m_socket
,
0
)
==
false
)
{
DEBUG
(
"cannot read from socket"
);
return
;
}
}
switch
(
m_state
)
switch
(
m_state
)
{
{
case
wait_for_process_info
:
case
wait_for_process_info
:
{
{
std
::
uint32_t
process_id
;
std
::
uint32_t
process_id
;
process_information
::
node_id_type
node_id
;
process_information
::
node_id_type
node_id
;
recv
(
m_socket
,
&
process_id
,
sizeof
(
std
::
uint32_t
),
0
);
memcpy
(
&
process_id
,
m_buf
.
data
(),
sizeof
(
std
::
uint32_t
));
recv
(
m_socket
,
node_id
.
data
(),
node_id
.
size
(),
0
);
memcpy
(
node_id
.
data
(),
m_buf
.
data
()
+
sizeof
(
std
::
uint32_t
),
process_information
::
node_id_size
);
m_peer
.
reset
(
new
process_information
(
process_id
,
node_id
));
m_peer
.
reset
(
new
process_information
(
process_id
,
node_id
));
// inform mailman about new peer
// inform mailman about new peer
nm
->
send_to_mailman
(
make_any_tuple
(
m_socket
,
m_peer
));
nm
->
send_to_mailman
(
make_any_tuple
(
m_socket
,
m_peer
));
...
@@ -196,28 +206,21 @@ class po_peer
...
@@ -196,28 +206,21 @@ class po_peer
<<
m_peer
->
process_id
()
<<
m_peer
->
process_id
()
<<
"@"
<<
"@"
<<
to_string
(
m_peer
->
node_id
()));
<<
to_string
(
m_peer
->
node_id
()));
// fall through and try to read more from socket
m_buf
.
reset
(
sizeof
(
std
::
uint32_t
));
break
;
}
}
case
wait_for_msg_size
:
case
wait_for_msg_size
:
{
{
recv
(
m_socket
,
&
msg_size
,
sizeof
(
std
::
uint32_t
),
0
);
std
::
uint32_t
msg_size
;
if
(
msg_size
>
(
16
*
1024
*
1024
))
memcpy
(
&
msg_size
,
m_buf
.
data
(),
sizeof
(
std
::
uint32_t
));
{
m_buf
.
reset
(
msg_size
);
// maximum of 16MB
return
;
}
if
(
msg_buf
.
size
()
<
msg_size
)
{
msg_buf
.
resize
(
msg_size
);
}
m_state
=
read_message
;
m_state
=
read_message
;
// fall through and try to read more from socket
break
;
}
}
case
read_message
:
case
read_message
:
{
{
recv
(
m_socket
,
msg_buf
.
data
(),
msg_size
,
0
);
addressed_message
msg
;
addressed_message
msg
;
binary_deserializer
bd
(
m
sg_buf
.
data
(),
msg_size
);
binary_deserializer
bd
(
m
_buf
.
data
(),
m_buf
.
size
()
);
try
try
{
{
meta_msg
->
deserialize
(
&
msg
,
&
bd
);
meta_msg
->
deserialize
(
&
msg
,
&
bd
);
...
@@ -287,6 +290,7 @@ class po_peer
...
@@ -287,6 +290,7 @@ class po_peer
}
}
}
}
);
);
m_buf
.
reset
(
sizeof
(
std
::
uint32_t
));
m_state
=
wait_for_msg_size
;
m_state
=
wait_for_msg_size
;
break
;
break
;
}
}
...
...
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