Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Beyond Protocol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Beyond AKA
Beyond Protocol
Commits
4ef56159
Commit
4ef56159
authored
2 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Add recv check
parent
750a36c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/peer.cpp
+5
-2
5 additions, 2 deletions
src/peer.cpp
src/peer.hpp
+1
-0
1 addition, 0 deletions
src/peer.hpp
src/universe.cpp
+9
-3
9 additions, 3 deletions
src/universe.cpp
with
15 additions
and
5 deletions
src/peer.cpp
+
5
−
2
View file @
4ef56159
...
...
@@ -319,9 +319,8 @@ void Peer::data() {
recv_buf_
.
buffer_consumed
(
rc
);
// FIXME: This might get skipped incorrectly.
// However, it should be extremely unlikely given that recv is done already
//UNIQUE_LOCK(recv_mtx_, lk);
recv_checked_
.
clear
();
if
(
!
already_processing_
.
test_and_set
())
{
//lk.unlock();
...
...
@@ -363,9 +362,13 @@ bool Peer::_data() {
msgpack
::
object_handle
msg_handle
;
try
{
recv_checked_
.
test_and_set
();
bool
has_next
=
_has_next
()
&&
recv_buf_
.
next
(
msg_handle
);
if
(
!
has_next
)
{
already_processing_
.
clear
();
if
(
!
recv_checked_
.
test_and_set
()
&&
!
already_processing_
.
test_and_set
())
{
return
_data
();
}
return
false
;
}
}
catch
(
const
std
::
exception
&
ex
)
{
...
...
This diff is collapsed.
Click to expand it.
src/peer.hpp
+
1
−
0
View file @
4ef56159
...
...
@@ -245,6 +245,7 @@ private: // Functions
}
std
::
atomic_flag
already_processing_
=
ATOMIC_FLAG_INIT
;
std
::
atomic_flag
recv_checked_
=
ATOMIC_FLAG_INIT
;
msgpack
::
unpacker
recv_buf_
;
//MUTEX recv_mtx_;
...
...
This diff is collapsed.
Click to expand it.
src/universe.cpp
+
9
−
3
View file @
4ef56159
...
...
@@ -292,6 +292,7 @@ socket_t Universe::_setDescriptors() {
SHARED_LOCK
(
net_mutex_
,
lk
);
impl_
->
pollfds
.
clear
();
impl_
->
idMap
.
clear
();
//Set file descriptor for the listening sockets.
for
(
auto
&
l
:
listeners_
)
{
...
...
@@ -502,7 +503,8 @@ void Universe::_run() {
#ifdef WIN32
int
errNum
=
WSAGetLastError
();
switch
(
errNum
)
{
default
:
LOG
(
WARNING
)
<<
"Unhandled poll error: "
<<
errNum
;
case
WSAENOTSOCK
:
continue
;
// Socket was closed
default
:
LOG
(
WARNING
)
<<
"Unhandled poll error: "
<<
errNum
;
}
#else
switch
(
errno
)
{
...
...
@@ -551,7 +553,11 @@ void Universe::_run() {
SOCKET
sock
=
s
->
_socket
();
if
(
sock
==
INVALID_SOCKET
)
continue
;
if
(
impl_
->
pollfds
[
impl_
->
idMap
[
sock
]].
revents
&
POLLERR
)
{
if
(
impl_
->
idMap
.
count
(
sock
)
==
0
)
continue
;
const
auto
&
fdstruct
=
impl_
->
pollfds
[
impl_
->
idMap
[
sock
]];
if
(
fdstruct
.
revents
&
POLLERR
)
{
if
(
s
->
socketError
())
{
//lk.unlock();
s
->
close
();
...
...
@@ -560,7 +566,7 @@ void Universe::_run() {
}
}
//If message received from this client then deal with it
if
(
impl_
->
pollfds
[
impl_
->
idMap
[
sock
]]
.
revents
&
POLLIN
)
{
if
(
fdstruct
.
revents
&
POLLIN
)
{
//lk.unlock();
s
->
data
();
//lk.lock();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment