Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
b6eae69c
Commit
b6eae69c
authored
Mar 09, 2016
by
Andreas Schmidt
Browse files
Stop saving lock positions to stack variables.
parent
bd741649
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/prrt/socket.c
View file @
b6eae69c
...
...
@@ -111,19 +111,17 @@ int PrrtSocket_send(PrrtSocket *sock_ptr, const uint8_t *data, const size_t data
int32_t
PrrtSocket_recv
(
PrrtSocket
*
sock_ptr
,
void
*
buf_ptr
)
{
check
(
sock_ptr
->
is_sender
==
false
,
"Cannot receive on sender socket."
)
pthread_mutex_t
filledMutex
=
sock_ptr
->
inQueueFilledMutex
;
pthread_mutex_t
closingMutex
=
sock_ptr
->
closingMutex
;
while
(
1
)
{
check
(
pthread_mutex_lock
(
&
f
illedMutex
)
==
0
,
"Lock failed."
);
check
(
pthread_mutex_lock
(
&
sock_ptr
->
inQueueF
illedMutex
)
==
0
,
"Lock failed."
);
while
(
List_count
(
sock_ptr
->
inQueue
)
==
0
)
{
check
(
pthread_mutex_lock
(
&
closingMutex
)
==
0
,
"Lock failed."
);
check
(
pthread_mutex_lock
(
&
sock_ptr
->
closingMutex
)
==
0
,
"Lock failed."
);
if
(
sock_ptr
->
closing
)
{
check
(
pthread_mutex_unlock
(
&
closingMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_mutex_unlock
(
&
f
illedMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
closingMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
inQueueF
illedMutex
)
==
0
,
"Unlock failed."
);
return
-
1
;
}
check
(
pthread_mutex_unlock
(
&
closingMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_cond_wait
(
&
sock_ptr
->
inQueueFilledCv
,
&
f
illedMutex
)
==
0
,
"Wait failed."
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
closingMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_cond_wait
(
&
sock_ptr
->
inQueueFilledCv
,
&
sock_ptr
->
inQueueF
illedMutex
)
==
0
,
"Wait failed."
);
}
PrrtPacket
*
packet
=
List_shift
(
sock_ptr
->
inQueue
);
...
...
@@ -131,7 +129,7 @@ int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr) {
PrrtPacket_copy_payload_to_buffer
(
buf_ptr
,
packet
,
PRRT_PACKET_DATA_HEADER_SIZE
);
PrrtPacket_destroy
(
packet
);
check
(
pthread_mutex_unlock
(
&
f
illedMutex
)
==
0
,
"Unlock failed."
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
inQueueF
illedMutex
)
==
0
,
"Unlock failed."
);
return
len
;
}
error:
...
...
Write
Preview
Supports
Markdown
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