Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
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
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
Libraries
pistache
Commits
fcf8f910
Unverified
Commit
fcf8f910
authored
Jan 01, 2019
by
Dennis Jenkins
Committed by
GitHub
Jan 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #402 from knowledge4igor/fix_data_races_in_client
Fix data races in client connection state logic
parents
7fe7bb56
e1784bf6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
include/pistache/client.h
include/pistache/client.h
+3
-3
src/client/client.cc
src/client/client.cc
+4
-4
No files found.
include/pistache/client.h
View file @
fcf8f910
...
@@ -41,9 +41,9 @@ struct Connection : public std::enable_shared_from_this<Connection> {
...
@@ -41,9 +41,9 @@ struct Connection : public std::enable_shared_from_this<Connection> {
Connection
()
Connection
()
:
fd
(
-
1
)
:
fd
(
-
1
)
,
requestEntry
(
nullptr
)
,
requestEntry
(
nullptr
)
,
connectionState_
(
NotConnected
)
{
{
state_
.
store
(
static_cast
<
uint32_t
>
(
State
::
Idle
));
state_
.
store
(
static_cast
<
uint32_t
>
(
State
::
Idle
));
connectionState_
.
store
(
NotConnected
);
}
}
struct
RequestData
{
struct
RequestData
{
...
@@ -133,7 +133,7 @@ private:
...
@@ -133,7 +133,7 @@ private:
struct
sockaddr_in
saddr
;
struct
sockaddr_in
saddr
;
std
::
unique_ptr
<
RequestEntry
>
requestEntry
;
std
::
unique_ptr
<
RequestEntry
>
requestEntry
;
std
::
atomic
<
uint32_t
>
state_
;
std
::
atomic
<
uint32_t
>
state_
;
ConnectionState
connectionState_
;
std
::
atomic
<
ConnectionState
>
connectionState_
;
std
::
shared_ptr
<
Transport
>
transport_
;
std
::
shared_ptr
<
Transport
>
transport_
;
Queue
<
RequestData
>
requestsQueue
;
Queue
<
RequestData
>
requestsQueue
;
...
...
src/client/client.cc
View file @
fcf8f910
...
@@ -355,14 +355,14 @@ Connection::connect(const Address& addr)
...
@@ -355,14 +355,14 @@ Connection::connect(const Address& addr)
make_non_blocking
(
sfd
);
make_non_blocking
(
sfd
);
connectionState_
=
Connecting
;
connectionState_
.
store
(
Connecting
)
;
fd
=
sfd
;
fd
=
sfd
;
transport_
->
asyncConnect
(
shared_from_this
(),
addr
->
ai_addr
,
addr
->
ai_addrlen
)
transport_
->
asyncConnect
(
shared_from_this
(),
addr
->
ai_addr
,
addr
->
ai_addrlen
)
.
then
([
=
]()
{
.
then
([
=
]()
{
socklen_t
len
=
sizeof
(
saddr
);
socklen_t
len
=
sizeof
(
saddr
);
getsockname
(
sfd
,
(
struct
sockaddr
*
)
&
saddr
,
&
len
);
getsockname
(
sfd
,
(
struct
sockaddr
*
)
&
saddr
,
&
len
);
connectionState_
=
Connected
;
connectionState_
.
store
(
Connected
)
;
processRequestQueue
();
processRequestQueue
();
},
ExceptionPrinter
());
},
ExceptionPrinter
());
break
;
break
;
...
@@ -388,12 +388,12 @@ Connection::isIdle() const {
...
@@ -388,12 +388,12 @@ Connection::isIdle() const {
bool
bool
Connection
::
isConnected
()
const
{
Connection
::
isConnected
()
const
{
return
connectionState_
==
Connected
;
return
connectionState_
.
load
()
==
Connected
;
}
}
void
void
Connection
::
close
()
{
Connection
::
close
()
{
connectionState_
=
NotConnected
;
connectionState_
.
store
(
NotConnected
)
;
::
close
(
fd
);
::
close
(
fd
);
}
}
...
...
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