##// END OF EJS Templates
commandserver: extract function that serves for the current connection...
Yuya Nishihara -
r29543:d74b8a4f default
parent child Browse files
Show More
@@ -533,9 +533,8 class chgcmdserver(commandserver.server)
533 'setumask': setumask})
533 'setumask': setumask})
534
534
535 class _requesthandler(commandserver._requesthandler):
535 class _requesthandler(commandserver._requesthandler):
536 def _createcmdserver(self, conn, fin, fout):
536 def _createcmdserver(self, repo, conn, fin, fout):
537 ui = self.server.ui
537 ui = self.server.ui
538 repo = self.server.repo
539 return chgcmdserver(ui, repo, fin, fout, conn,
538 return chgcmdserver(ui, repo, fin, fout, conn,
540 self.server.hashstate, self.server.baseaddress)
539 self.server.hashstate, self.server.baseaddress)
541
540
@@ -338,8 +338,8 class pipeservice(object):
338 sv.cleanup()
338 sv.cleanup()
339 _restoreio(ui, fin, fout)
339 _restoreio(ui, fin, fout)
340
340
341 class _requesthandler(socketserver.BaseRequestHandler):
341 def _serverequest(ui, repo, conn, createcmdserver):
342 def handle(self):
342 if True: # TODO: unindent
343 # use a different process group from the master process, making this
343 # use a different process group from the master process, making this
344 # process pass kernel "is_current_pgrp_orphaned" check so signals like
344 # process pass kernel "is_current_pgrp_orphaned" check so signals like
345 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
345 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
@@ -347,14 +347,12 class _requesthandler(socketserver.BaseR
347 # change random state otherwise forked request handlers would have a
347 # change random state otherwise forked request handlers would have a
348 # same state inherited from parent.
348 # same state inherited from parent.
349 random.seed()
349 random.seed()
350 ui = self.server.ui
351
350
352 conn = self.request
353 fin = conn.makefile('rb')
351 fin = conn.makefile('rb')
354 fout = conn.makefile('wb')
352 fout = conn.makefile('wb')
355 sv = None
353 sv = None
356 try:
354 try:
357 sv = self._createcmdserver(conn, fin, fout)
355 sv = createcmdserver(repo, conn, fin, fout)
358 try:
356 try:
359 sv.serve()
357 sv.serve()
360 # handle exceptions that may be raised by command server. most of
358 # handle exceptions that may be raised by command server. most of
@@ -387,9 +385,13 class _requesthandler(socketserver.BaseR
387 # trigger __del__ since ForkingMixIn uses os._exit
385 # trigger __del__ since ForkingMixIn uses os._exit
388 gc.collect()
386 gc.collect()
389
387
390 def _createcmdserver(self, conn, fin, fout):
388 class _requesthandler(socketserver.BaseRequestHandler):
389 def handle(self):
390 _serverequest(self.server.ui, self.server.repo, self.request,
391 self._createcmdserver)
392
393 def _createcmdserver(self, repo, conn, fin, fout):
391 ui = self.server.ui
394 ui = self.server.ui
392 repo = self.server.repo
393 return server(ui, repo, fin, fout)
395 return server(ui, repo, fin, fout)
394
396
395 class unixservice(object):
397 class unixservice(object):
General Comments 0
You need to be logged in to leave comments. Login now