Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Donald Chen
pc-ble-driver-sd_api_v6
Commits
2f649c9a
Commit
2f649c9a
authored
Feb 14, 2018
by
bencefr
Browse files
Fixed serialization transport to access queue in a safe manner
parent
3fcdc514
Changes
1
Show whitespace changes
Inline
Side-by-side
src/common/transport/serialization_transport.cpp
View file @
2f649c9a
...
...
@@ -160,12 +160,15 @@ uint32_t SerializationTransport::send(uint8_t *cmdBuffer, uint32_t cmdLength, ui
// Event Thread
void
SerializationTransport
::
eventHandlingRunner
()
{
while
(
runEventThread
)
{
do
{
std
::
unique_lock
<
std
::
mutex
>
eventLock
(
eventMutex
);
eventWaitCondition
.
wait
(
eventLock
);
while
(
!
eventQueue
.
empty
())
{
eventData_t
eventData
=
eventQueue
.
front
();
eventQueue
.
pop
();
eventLock
.
unlock
();
// Allocate memory to store decoded event including an unknown quantity of padding
// Set security context
...
...
@@ -188,22 +191,10 @@ void SerializationTransport::eventHandlingRunner()
}
free
(
eventData
.
data
);
}
std
::
unique_lock
<
std
::
mutex
>
eventLock
(
eventMutex
);
if
(
!
runEventThread
)
{
break
;
}
if
(
!
eventQueue
.
empty
())
{
continue
;
}
eventWaitCondition
.
wait
(
eventLock
);
eventLock
.
lock
();
}
}
while
(
runEventThread
);
}
// Read Thread
...
...
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