changeset 28770:97c8da2f89f9

chgserver: change random state after fork Before this patch, extensions expecting a different random state per command will break since the chg request handler will inherit a same random state from the parent daemon process. This patch addresses the issue by calling random.seed() after fork.
author Jun Wu <quark@fb.com>
date Mon, 04 Apr 2016 01:59:57 +0100
parents 222f482930c8
children 9366b18ba103
files hgext/chgserver.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/chgserver.py	Mon Apr 04 02:36:05 2016 +0100
+++ b/hgext/chgserver.py	Mon Apr 04 01:59:57 2016 +0100
@@ -45,6 +45,7 @@
 import gc
 import inspect
 import os
+import random
 import re
 import struct
 import sys
@@ -540,6 +541,9 @@
         # process pass kernel "is_current_pgrp_orphaned" check so signals like
         # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
         os.setpgid(0, 0)
+        # change random state otherwise forked request handlers would have a
+        # same state inherited from parent.
+        random.seed()
         ui = self.server.ui
         repo = self.server.repo
         sv = None