cpython: 28b465d8c519 (original) (raw)
Mercurial > cpython
changeset 95292:28b465d8c519
Issue #22181: os.urandom() now releases the GIL when the getrandom() implementation is used. [#22181]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Mon, 30 Mar 2015 11:16:40 +0200 |
parents | e46c3138b5b3 |
children | 7f1015e4277a |
files | Python/random.c |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-)[+] [-] Python/random.c 13 |
line wrap: on
line diff
--- a/Python/random.c +++ b/Python/random.c @@ -115,9 +115,18 @@ py_getrandom(void *buffer, Py_ssize_t si while (0 < size) { errno = 0;
/* the libc doesn't expose getrandom() yet, see:[](#l1.7)
/* Use syscall() because the libc doesn't expose getrandom() yet, see:[](#l1.9) * https://sourceware.org/bugzilla/show_bug.cgi?id=17252 */[](#l1.10)
n = syscall(SYS_getrandom, buffer, size, flags);[](#l1.11)
if (raise) {[](#l1.12)
Py_BEGIN_ALLOW_THREADS[](#l1.13)
n = syscall(SYS_getrandom, buffer, size, flags);[](#l1.14)
Py_END_ALLOW_THREADS[](#l1.15)
}[](#l1.16)
else {[](#l1.17)
n = syscall(SYS_getrandom, buffer, size, flags);[](#l1.18)
}[](#l1.19)