Show More
@@ -25,8 +25,6 b' from . import (' | |||||
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
27 |
|
27 | |||
28 | socketserver = util.socketserver |
|
|||
29 |
|
||||
30 | logfile = None |
|
28 | logfile = None | |
31 |
|
29 | |||
32 | def log(*args): |
|
30 | def log(*args): | |
@@ -423,48 +421,19 b' class unixservicehandler(object):' | |||||
423 | serves for the current connection""" |
|
421 | serves for the current connection""" | |
424 | return server(self.ui, repo, fin, fout) |
|
422 | return server(self.ui, repo, fin, fout) | |
425 |
|
423 | |||
426 | class _requesthandler(socketserver.BaseRequestHandler): |
|
424 | class unixforkingservice(object): | |
427 | def handle(self): |
|
|||
428 | _serverequest(self.server.ui, self.server.repo, self.request, |
|
|||
429 | self._createcmdserver) |
|
|||
430 |
|
||||
431 | def _createcmdserver(self, repo, conn, fin, fout): |
|
|||
432 | ui = self.server.ui |
|
|||
433 | return server(ui, repo, fin, fout) |
|
|||
434 |
|
||||
435 | class unixservice(object): |
|
|||
436 | """ |
|
425 | """ | |
437 | Listens on unix domain socket and forks server per connection |
|
426 | Listens on unix domain socket and forks server per connection | |
438 | """ |
|
427 | """ | |
439 | def __init__(self, ui, repo, opts): |
|
428 | ||
|
429 | def __init__(self, ui, repo, opts, handler=None): | |||
440 | self.ui = ui |
|
430 | self.ui = ui | |
441 | self.repo = repo |
|
431 | self.repo = repo | |
442 | self.address = opts['address'] |
|
432 | self.address = opts['address'] | |
443 |
if not util.safehasattr(socket |
|
433 | if not util.safehasattr(socket, 'AF_UNIX'): | |
444 | raise error.Abort(_('unsupported platform')) |
|
434 | raise error.Abort(_('unsupported platform')) | |
445 | if not self.address: |
|
435 | if not self.address: | |
446 | raise error.Abort(_('no socket path specified with --address')) |
|
436 | raise error.Abort(_('no socket path specified with --address')) | |
447 |
|
||||
448 | def init(self): |
|
|||
449 | class cls(socketserver.ForkingMixIn, socketserver.UnixStreamServer): |
|
|||
450 | ui = self.ui |
|
|||
451 | repo = self.repo |
|
|||
452 | self.server = cls(self.address, _requesthandler) |
|
|||
453 | self.ui.status(_('listening at %s\n') % self.address) |
|
|||
454 | self.ui.flush() # avoid buffering of status message |
|
|||
455 |
|
||||
456 | def _cleanup(self): |
|
|||
457 | os.unlink(self.address) |
|
|||
458 |
|
||||
459 | def run(self): |
|
|||
460 | try: |
|
|||
461 | self.server.serve_forever() |
|
|||
462 | finally: |
|
|||
463 | self._cleanup() |
|
|||
464 |
|
||||
465 | class unixforkingservice(unixservice): |
|
|||
466 | def __init__(self, ui, repo, opts, handler=None): |
|
|||
467 | super(unixforkingservice, self).__init__(ui, repo, opts) |
|
|||
468 | self._servicehandler = handler or unixservicehandler(ui) |
|
437 | self._servicehandler = handler or unixservicehandler(ui) | |
469 | self._sock = None |
|
438 | self._sock = None | |
470 | self._oldsigchldhandler = None |
|
439 | self._oldsigchldhandler = None |
General Comments 0
You need to be logged in to leave comments.
Login now