Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asyncmsg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
atlas-tdaq-software
asyncmsg
Commits
8f06523c
Commit
8f06523c
authored
11 years ago
by
Tommaso Colombo
Browse files
Options
Downloads
Patches
Plain Diff
Session: set state variables *before* calling state change completion methods
parent
f9f6ebd8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Session.cxx
+10
-10
10 additions, 10 deletions
src/Session.cxx
with
10 additions
and
10 deletions
src/Session.cxx
+
10
−
10
View file @
8f06523c
...
@@ -47,8 +47,8 @@ void Session::asyncOpen(const std::string& localName,
...
@@ -47,8 +47,8 @@ void Session::asyncOpen(const std::string& localName,
m_socket
.
async_connect
(
remoteEndpoint
,
m_strand
.
wrap
(
m_socket
.
async_connect
(
remoteEndpoint
,
m_strand
.
wrap
(
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
)
{
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
)
{
if
(
error
)
{
if
(
error
)
{
onOpenError
(
error
);
abortOpen
();
abortOpen
();
onOpenError
(
error
);
}
}
else
{
else
{
startOpen
(
self
);
startOpen
(
self
);
...
@@ -72,21 +72,21 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
...
@@ -72,21 +72,21 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
boost
::
asio
::
async_write
(
m_socket
,
boost
::
make_iterator_range
(
m_sendBuffers
),
m_strand
.
wrap
(
boost
::
asio
::
async_write
(
m_socket
,
boost
::
make_iterator_range
(
m_sendBuffers
),
m_strand
.
wrap
(
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
if
(
error
)
{
if
(
error
)
{
onOpenError
(
error
);
abortOpen
();
abortOpen
();
onOpenError
(
error
);
return
;
return
;
}
}
// 3. Receive the HELLO message header
// 3. Receive the HELLO message header
boost
::
asio
::
async_read
(
m_socket
,
boost
::
asio
::
buffer
(
m_recvHeader
.
data
()),
m_strand
.
wrap
(
boost
::
asio
::
async_read
(
m_socket
,
boost
::
asio
::
buffer
(
m_recvHeader
.
data
()),
m_strand
.
wrap
(
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
[
this
,
self
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
if
(
error
)
{
if
(
error
)
{
onOpenError
(
error
);
abortOpen
();
abortOpen
();
onOpenError
(
error
);
return
;
return
;
}
}
if
(
m_recvHeader
.
typeId
()
!=
HELLO_MESSAGE_ID
)
{
if
(
m_recvHeader
.
typeId
()
!=
HELLO_MESSAGE_ID
)
{
onOpenError
(
Error
::
UNEXPECTED_MESSAGE_TYPE
);
abortOpen
();
abortOpen
();
onOpenError
(
Error
::
UNEXPECTED_MESSAGE_TYPE
);
return
;
return
;
}
}
// 4. Receive the HELLO message body
// 4. Receive the HELLO message body
...
@@ -94,8 +94,8 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
...
@@ -94,8 +94,8 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
boost
::
asio
::
async_read
(
m_socket
,
boost
::
asio
::
buffer
(
*
storage
),
m_strand
.
wrap
(
boost
::
asio
::
async_read
(
m_socket
,
boost
::
asio
::
buffer
(
*
storage
),
m_strand
.
wrap
(
[
this
,
self
,
storage
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
[
this
,
self
,
storage
]
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
)
{
if
(
error
)
{
if
(
error
)
{
onOpenError
(
error
);
abortOpen
();
abortOpen
();
onOpenError
(
error
);
return
;
return
;
}
}
m_remoteName
.
insert
(
m_remoteName
.
begin
(),
storage
->
begin
(),
storage
->
end
());
m_remoteName
.
insert
(
m_remoteName
.
begin
(),
storage
->
begin
(),
storage
->
end
());
...
@@ -108,11 +108,14 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
...
@@ -108,11 +108,14 @@ void Session::startOpen(const std::shared_ptr<Session>& self)
void
Session
::
abortOpen
()
void
Session
::
abortOpen
()
{
{
m_localName
.
clear
();
m_remoteName
.
clear
();
m_state
=
State
::
CLOSED
;
// abortOpen() is called if there was an error in one of the I/O operations in asyncOpen() or
// abortOpen() is called if there was an error in one of the I/O operations in asyncOpen() or
// startOpen(). We have to distinguish two cases:
// startOpen(). We have to distinguish two cases:
// 1) The error occurred because asyncClose() closed m_socket
// 1) The error occurred because asyncClose() closed m_socket
// 2) There was a "real" I/O error
// 2) There was a "real" I/O error
if
(
m_state
==
State
::
CLOSE_PENDING
)
{
if
(
m_state
==
State
::
CLOSE_PENDING
)
{
// case 1)
// case 1)
onClose
();
onClose
();
...
@@ -122,9 +125,6 @@ void Session::abortOpen()
...
@@ -122,9 +125,6 @@ void Session::abortOpen()
boost
::
system
::
error_code
ignoredError
;
boost
::
system
::
error_code
ignoredError
;
m_socket
.
close
(
ignoredError
);
m_socket
.
close
(
ignoredError
);
}
}
m_localName
.
clear
();
m_remoteName
.
clear
();
m_state
=
State
::
CLOSED
;
}
}
...
@@ -156,10 +156,10 @@ void Session::asyncClose()
...
@@ -156,10 +156,10 @@ void Session::asyncClose()
void
Session
::
checkClose
()
void
Session
::
checkClose
()
{
{
if
(
m_state
==
State
::
CLOSE_PENDING
&&
m_recvNPending
==
0
&&
m_sendQueue
.
empty
())
{
if
(
m_state
==
State
::
CLOSE_PENDING
&&
m_recvNPending
==
0
&&
m_sendQueue
.
empty
())
{
onClose
();
m_localName
.
clear
();
m_localName
.
clear
();
m_remoteName
.
clear
();
m_remoteName
.
clear
();
m_state
=
State
::
CLOSED
;
m_state
=
State
::
CLOSED
;
onClose
();
}
}
}
}
...
...
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