re-init openssl PRNG when forking for prewarm
This commit is contained in:
parent
dfec88ed15
commit
8011801549
@ -53,6 +53,11 @@ class Child:
|
|||||||
child_process_pid: int
|
child_process_pid: int
|
||||||
|
|
||||||
|
|
||||||
|
def reinit_openssl_prng() -> None:
|
||||||
|
import ssl
|
||||||
|
ssl.RAND_add(os.urandom(64), 0.0)
|
||||||
|
|
||||||
|
|
||||||
def wait_for_child_death(child_pid: int, timeout: float = 1) -> Optional[int]:
|
def wait_for_child_death(child_pid: int, timeout: float = 1) -> Optional[int]:
|
||||||
st = time.monotonic()
|
st = time.monotonic()
|
||||||
while time.monotonic() - st < timeout:
|
while time.monotonic() - st < timeout:
|
||||||
@ -326,6 +331,7 @@ def fork(shm_address: str, free_non_child_resources: Callable[[], None]) -> Tupl
|
|||||||
# master process
|
# master process
|
||||||
os.close(w)
|
os.close(w)
|
||||||
os.close(ready_fd_read)
|
os.close(ready_fd_read)
|
||||||
|
reinit_openssl_prng()
|
||||||
poll = select.poll()
|
poll = select.poll()
|
||||||
poll.register(r, select.POLLIN)
|
poll.register(r, select.POLLIN)
|
||||||
tuple(poll.poll())
|
tuple(poll.poll())
|
||||||
@ -441,8 +447,9 @@ class SocketChild:
|
|||||||
r, w = safe_pipe()
|
r, w = safe_pipe()
|
||||||
self.pid = os.fork()
|
self.pid = os.fork()
|
||||||
if self.pid > 0:
|
if self.pid > 0:
|
||||||
os.close(w)
|
|
||||||
# master process
|
# master process
|
||||||
|
os.close(w)
|
||||||
|
reinit_openssl_prng()
|
||||||
if self.stdin > -1:
|
if self.stdin > -1:
|
||||||
os.close(self.stdin)
|
os.close(self.stdin)
|
||||||
self.stdin = -1
|
self.stdin = -1
|
||||||
@ -799,6 +806,7 @@ def fork_prewarm_process(opts: Options, use_exec: bool = False) -> Optional[Prew
|
|||||||
child_pid = os.fork()
|
child_pid = os.fork()
|
||||||
if child_pid:
|
if child_pid:
|
||||||
# master
|
# master
|
||||||
|
reinit_openssl_prng()
|
||||||
if not use_exec:
|
if not use_exec:
|
||||||
unix_socket.close()
|
unix_socket.close()
|
||||||
os.close(stdin_read)
|
os.close(stdin_read)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user