Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
846f8c94
Commit
846f8c94
authored
Aug 07, 2015
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix attach-related race condition in shm_mq_send_bytes.
Spotted by Antonin Houska.
parent
4eda0a64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
src/backend/storage/ipc/shm_mq.c
src/backend/storage/ipc/shm_mq.c
+21
-17
No files found.
src/backend/storage/ipc/shm_mq.c
View file @
846f8c94
...
@@ -777,33 +777,37 @@ shm_mq_send_bytes(shm_mq_handle *mqh, Size nbytes, const void *data,
...
@@ -777,33 +777,37 @@ shm_mq_send_bytes(shm_mq_handle *mqh, Size nbytes, const void *data,
return
SHM_MQ_DETACHED
;
return
SHM_MQ_DETACHED
;
}
}
if
(
available
==
0
)
if
(
available
==
0
&&
!
mqh
->
mqh_counterparty_attached
)
{
{
shm_mq_result
res
;
/*
/*
* The queue is full, so if the receiver isn't yet known to be
* The queue is full, so if the receiver isn't yet known to be
* attached, we must wait for that to happen.
* attached, we must wait for that to happen.
*/
*/
if
(
!
mqh
->
mqh_counterparty_attached
)
if
(
nowait
)
{
{
if
(
nowait
)
if
(
shm_mq_get_receiver
(
mq
)
==
NULL
)
{
{
if
(
shm_mq_get_receiver
(
mq
)
==
NULL
)
{
*
bytes_written
=
sent
;
return
SHM_MQ_WOULD_BLOCK
;
}
}
else
if
(
!
shm_mq_wait_internal
(
mq
,
&
mq
->
mq_receiver
,
mqh
->
mqh_handle
))
{
mq
->
mq_detached
=
true
;
*
bytes_written
=
sent
;
*
bytes_written
=
sent
;
return
SHM_MQ_
DETACHED
;
return
SHM_MQ_
WOULD_BLOCK
;
}
}
mqh
->
mqh_counterparty_attached
=
true
;
}
}
else
if
(
!
shm_mq_wait_internal
(
mq
,
&
mq
->
mq_receiver
,
mqh
->
mqh_handle
))
{
mq
->
mq_detached
=
true
;
*
bytes_written
=
sent
;
return
SHM_MQ_DETACHED
;
}
mqh
->
mqh_counterparty_attached
=
true
;
/*
* The receiver may have read some data after attaching, so we
* must not wait without rechecking the queue state.
*/
}
else
if
(
available
==
0
)
{
shm_mq_result
res
;
/* Let the receiver know that we need them to read some data. */
/* Let the receiver know that we need them to read some data. */
res
=
shm_mq_notify_receiver
(
mq
);
res
=
shm_mq_notify_receiver
(
mq
);
...
...
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