Mercurial > public > mercurial-scm > hg
comparison hgext/chgserver.py @ 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 | 2461f33c9f97 |
children | 983353035cec |
comparison
equal
deleted
inserted
replaced
28769:222f482930c8 | 28770:97c8da2f89f9 |
---|---|
43 import SocketServer | 43 import SocketServer |
44 import errno | 44 import errno |
45 import gc | 45 import gc |
46 import inspect | 46 import inspect |
47 import os | 47 import os |
48 import random | |
48 import re | 49 import re |
49 import struct | 50 import struct |
50 import sys | 51 import sys |
51 import threading | 52 import threading |
52 import time | 53 import time |
538 def handle(self): | 539 def handle(self): |
539 # use a different process group from the master process, making this | 540 # use a different process group from the master process, making this |
540 # process pass kernel "is_current_pgrp_orphaned" check so signals like | 541 # process pass kernel "is_current_pgrp_orphaned" check so signals like |
541 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. | 542 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. |
542 os.setpgid(0, 0) | 543 os.setpgid(0, 0) |
544 # change random state otherwise forked request handlers would have a | |
545 # same state inherited from parent. | |
546 random.seed() | |
543 ui = self.server.ui | 547 ui = self.server.ui |
544 repo = self.server.repo | 548 repo = self.server.repo |
545 sv = None | 549 sv = None |
546 try: | 550 try: |
547 sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection, | 551 sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection, |