Show More
@@ -41,18 +41,15 b' Config' | |||
|
41 | 41 | from __future__ import absolute_import |
|
42 | 42 | |
|
43 | 43 | import errno |
|
44 | import gc | |
|
45 | 44 | import hashlib |
|
46 | 45 | import inspect |
|
47 | 46 | import os |
|
48 | import random | |
|
49 | 47 | import re |
|
50 | 48 | import signal |
|
51 | 49 | import struct |
|
52 | 50 | import sys |
|
53 | 51 | import threading |
|
54 | 52 | import time |
|
55 | import traceback | |
|
56 | 53 | |
|
57 | 54 | from mercurial.i18n import _ |
|
58 | 55 | |
@@ -535,46 +532,7 b' class chgcmdserver(commandserver.server)' | |||
|
535 | 532 | 'setenv': setenv, |
|
536 | 533 | 'setumask': setumask}) |
|
537 | 534 | |
|
538 | # copied from mercurial/commandserver.py | |
|
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 | ||
|
535 | class _requesthandler(commandserver._requesthandler): | |
|
578 | 536 | def _createcmdserver(self): |
|
579 | 537 | ui = self.server.ui |
|
580 | 538 | repo = self.server.repo |
@@ -8,7 +8,9 b'' | |||
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import errno |
|
11 | import gc | |
|
11 | 12 | import os |
|
13 | import random | |
|
12 | 14 | import struct |
|
13 | 15 | import sys |
|
14 | 16 | import traceback |
@@ -338,6 +340,13 b' class pipeservice(object):' | |||
|
338 | 340 | |
|
339 | 341 | class _requesthandler(socketserver.StreamRequestHandler): |
|
340 | 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 | 350 | ui = self.server.ui |
|
342 | 351 | sv = None |
|
343 | 352 | try: |
@@ -364,6 +373,9 b' class _requesthandler(socketserver.Strea' | |||
|
364 | 373 | cerr = channeledoutput(self.wfile, 'e') |
|
365 | 374 | traceback.print_exc(file=cerr) |
|
366 | 375 | raise |
|
376 | finally: | |
|
377 | # trigger __del__ since ForkingMixIn uses os._exit | |
|
378 | gc.collect() | |
|
367 | 379 | |
|
368 | 380 | def _createcmdserver(self): |
|
369 | 381 | ui = self.server.ui |
General Comments 0
You need to be logged in to leave comments.
Login now