Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
aadef2b4
Commit
aadef2b4
authored
Feb 25, 2019
by
Davin Potts
Committed by
GitHub
Feb 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36102: Prepend slash to all POSIX shared memory block names (#12036)
parent
8377cd4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
Lib/multiprocessing/shared_memory.py
Lib/multiprocessing/shared_memory.py
+10
-4
No files found.
Lib/multiprocessing/shared_memory.py
View file @
aadef2b4
...
...
@@ -30,7 +30,7 @@ _SHM_SAFE_NAME_LENGTH = 14
# Shared memory block name prefix
if
_USE_POSIX
:
_SHM_NAME_PREFIX
=
'psm_'
_SHM_NAME_PREFIX
=
'
/
psm_'
else
:
_SHM_NAME_PREFIX
=
'wnsm_'
...
...
@@ -68,6 +68,7 @@ class SharedMemory:
_buf
=
None
_flags
=
os
.
O_RDWR
_mode
=
0o600
_prepend_leading_slash
=
True
if
_USE_POSIX
else
False
def
__init__
(
self
,
name
=
None
,
create
=
False
,
size
=
0
):
if
not
size
>=
0
:
...
...
@@ -95,6 +96,7 @@ class SharedMemory:
self
.
_name
=
name
break
else
:
name
=
"/"
+
name
if
self
.
_prepend_leading_slash
else
name
self
.
_fd
=
_posixshmem
.
shm_open
(
name
,
self
.
_flags
,
...
...
@@ -198,7 +200,11 @@ class SharedMemory:
@
property
def
name
(
self
):
"Unique name that identifies the shared memory block."
return
self
.
_name
reported_name
=
self
.
_name
if
_USE_POSIX
and
self
.
_prepend_leading_slash
:
if
self
.
_name
.
startswith
(
"/"
):
reported_name
=
self
.
_name
[
1
:]
return
reported_name
@
property
def
size
(
self
):
...
...
@@ -224,8 +230,8 @@ class SharedMemory:
In order to ensure proper cleanup of resources, unlink should be
called once (and only once) across all processes which have access
to the shared memory block."""
if
_USE_POSIX
and
self
.
name
:
_posixshmem
.
shm_unlink
(
self
.
name
)
if
_USE_POSIX
and
self
.
_
name
:
_posixshmem
.
shm_unlink
(
self
.
_
name
)
_encoding
=
"utf8"
...
...
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