Show More
@@ -41,18 +41,15 b' Config' | |||||
41 | from __future__ import absolute_import |
|
41 | from __future__ import absolute_import | |
42 |
|
42 | |||
43 | import errno |
|
43 | import errno | |
44 | import gc |
|
|||
45 | import hashlib |
|
44 | import hashlib | |
46 | import inspect |
|
45 | import inspect | |
47 | import os |
|
46 | import os | |
48 | import random |
|
|||
49 | import re |
|
47 | import re | |
50 | import signal |
|
48 | import signal | |
51 | import struct |
|
49 | import struct | |
52 | import sys |
|
50 | import sys | |
53 | import threading |
|
51 | import threading | |
54 | import time |
|
52 | import time | |
55 | import traceback |
|
|||
56 |
|
53 | |||
57 | from mercurial.i18n import _ |
|
54 | from mercurial.i18n import _ | |
58 |
|
55 | |||
@@ -535,46 +532,7 b' class chgcmdserver(commandserver.server)' | |||||
535 | 'setenv': setenv, |
|
532 | 'setenv': setenv, | |
536 | 'setumask': setumask}) |
|
533 | 'setumask': setumask}) | |
537 |
|
534 | |||
538 | # copied from mercurial/commandserver.py |
|
535 | class _requesthandler(commandserver._requesthandler): | |
539 | class _requesthandler(socketserver.StreamRequestHandler): |
|
|||
540 | def handle(self): |
|
|||
541 | # use a different process group from the master process, making this |
|
|||
542 | # process pass kernel "is_current_pgrp_orphaned" check so signals like |
|
|||
543 | # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. |
|
|||
544 | os.setpgid(0, 0) |
|
|||
545 | # change random state otherwise forked request handlers would have a |
|
|||
546 | # same state inherited from parent. |
|
|||
547 | random.seed() |
|
|||
548 | ui = self.server.ui |
|
|||
549 | sv = None |
|
|||
550 | try: |
|
|||
551 | sv = self._createcmdserver() |
|
|||
552 | try: |
|
|||
553 | sv.serve() |
|
|||
554 | # handle exceptions that may be raised by command server. most of |
|
|||
555 | # known exceptions are caught by dispatch. |
|
|||
556 | except error.Abort as inst: |
|
|||
557 | ui.warn(_('abort: %s\n') % inst) |
|
|||
558 | except IOError as inst: |
|
|||
559 | if inst.errno != errno.EPIPE: |
|
|||
560 | raise |
|
|||
561 | except KeyboardInterrupt: |
|
|||
562 | pass |
|
|||
563 | finally: |
|
|||
564 | sv.cleanup() |
|
|||
565 | except: # re-raises |
|
|||
566 | # also write traceback to error channel. otherwise client cannot |
|
|||
567 | # see it because it is written to server's stderr by default. |
|
|||
568 | if sv: |
|
|||
569 | cerr = sv.cerr |
|
|||
570 | else: |
|
|||
571 | cerr = commandserver.channeledoutput(self.wfile, 'e') |
|
|||
572 | traceback.print_exc(file=cerr) |
|
|||
573 | raise |
|
|||
574 | finally: |
|
|||
575 | # trigger __del__ since ForkingMixIn uses os._exit |
|
|||
576 | gc.collect() |
|
|||
577 |
|
||||
578 | def _createcmdserver(self): |
|
536 | def _createcmdserver(self): | |
579 | ui = self.server.ui |
|
537 | ui = self.server.ui | |
580 | repo = self.server.repo |
|
538 | repo = self.server.repo |
@@ -8,7 +8,9 b'' | |||||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import errno |
|
10 | import errno | |
|
11 | import gc | |||
11 | import os |
|
12 | import os | |
|
13 | import random | |||
12 | import struct |
|
14 | import struct | |
13 | import sys |
|
15 | import sys | |
14 | import traceback |
|
16 | import traceback | |
@@ -338,6 +340,13 b' class pipeservice(object):' | |||||
338 |
|
340 | |||
339 | class _requesthandler(socketserver.StreamRequestHandler): |
|
341 | class _requesthandler(socketserver.StreamRequestHandler): | |
340 | def handle(self): |
|
342 | def handle(self): | |
|
343 | # use a different process group from the master process, making this | |||
|
344 | # process pass kernel "is_current_pgrp_orphaned" check so signals like | |||
|
345 | # SIGTSTP, SIGTTIN, SIGTTOU are not ignored. | |||
|
346 | os.setpgid(0, 0) | |||
|
347 | # change random state otherwise forked request handlers would have a | |||
|
348 | # same state inherited from parent. | |||
|
349 | random.seed() | |||
341 | ui = self.server.ui |
|
350 | ui = self.server.ui | |
342 | sv = None |
|
351 | sv = None | |
343 | try: |
|
352 | try: | |
@@ -364,6 +373,9 b' class _requesthandler(socketserver.Strea' | |||||
364 | cerr = channeledoutput(self.wfile, 'e') |
|
373 | cerr = channeledoutput(self.wfile, 'e') | |
365 | traceback.print_exc(file=cerr) |
|
374 | traceback.print_exc(file=cerr) | |
366 | raise |
|
375 | raise | |
|
376 | finally: | |||
|
377 | # trigger __del__ since ForkingMixIn uses os._exit | |||
|
378 | gc.collect() | |||
367 |
|
379 | |||
368 | def _createcmdserver(self): |
|
380 | def _createcmdserver(self): | |
369 | ui = self.server.ui |
|
381 | ui = self.server.ui |
General Comments 0
You need to be logged in to leave comments.
Login now