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
|
||||
|
||||
|
||||
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]:
|
||||
st = time.monotonic()
|
||||
while time.monotonic() - st < timeout:
|
||||
@ -326,6 +331,7 @@ def fork(shm_address: str, free_non_child_resources: Callable[[], None]) -> Tupl
|
||||
# master process
|
||||
os.close(w)
|
||||
os.close(ready_fd_read)
|
||||
reinit_openssl_prng()
|
||||
poll = select.poll()
|
||||
poll.register(r, select.POLLIN)
|
||||
tuple(poll.poll())
|
||||
@ -441,8 +447,9 @@ class SocketChild:
|
||||
r, w = safe_pipe()
|
||||
self.pid = os.fork()
|
||||
if self.pid > 0:
|
||||
os.close(w)
|
||||
# master process
|
||||
os.close(w)
|
||||
reinit_openssl_prng()
|
||||
if self.stdin > -1:
|
||||
os.close(self.stdin)
|
||||
self.stdin = -1
|
||||
@ -799,6 +806,7 @@ def fork_prewarm_process(opts: Options, use_exec: bool = False) -> Optional[Prew
|
||||
child_pid = os.fork()
|
||||
if child_pid:
|
||||
# master
|
||||
reinit_openssl_prng()
|
||||
if not use_exec:
|
||||
unix_socket.close()
|
||||
os.close(stdin_read)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user