-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix (python) : Add support for multiprocessing module #8990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Nice work! It would be more convenient if |
OK. I will try to separate the Should I fold it into the I will not seperate the |
Great!
A new package will be preferable. I suppose we can safely remove
I see. |
#8993 has been merged. This PR is now ready for a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
+ errno = ENAMETOOLONG; | ||
+ return 0; | ||
+ } | ||
+ memcpy(buf, "@TERMUX_PREFIX@/tmp/shm.", 40); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why it end with a . ? Musl ends with /
Same goes in libandroid-posix-semaphore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename is appended to the path after, so we either have $PREFIX/tmp/shm.something
or $PREFIX/tmp/shm/something
. With $PREFIX/tmp/shm/
we would have to check if folder exists (and create it if it doesn't), so I suppose this is just a way to save a couple of lines of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hardcode the string length. The 40
here should be replaced with strlen("@TERMUX_PREFIX@/tmp/shm.")
or something. (See also #9007.)
+ return 0; | ||
+ } | ||
+ memcpy(buf, "@TERMUX_PREFIX@/tmp/shm.", 40); | ||
+ memcpy(buf+40, name, p-name+1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as #8990 (comment).
+ | ||
+int shm_open(const char *name, int flag, mode_t mode) | ||
+{ | ||
+ char buf[NAME_MAX+41]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost the same as #8990 (comment). The 41
here should be something like strlen("@TERMUX_PREFIX@/tmp/shm.")+1
.
+ | ||
+int shm_unlink(const char *name) | ||
+{ | ||
+ char buf[NAME_MAX+41]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with one python package that normally fails (papis). Everything now seem to work!
Bionic libc doesn't support
sem_open
,sem_close
andsem_unlink
. This fix contains a port of posix named semaphore and shared memory from musl libc and is used for python multiprocessing module. Note that Android has no /dev/shm, so the mapped file will be created at the temp directory of termux.Related issues: #570, #8938