Show More
@@ -25,8 +25,6 b' from . import (' | |||
|
25 | 25 | util, |
|
26 | 26 | ) |
|
27 | 27 | |
|
28 | socketserver = util.socketserver | |
|
29 | ||
|
30 | 28 | logfile = None |
|
31 | 29 | |
|
32 | 30 | def log(*args): |
@@ -423,48 +421,19 b' class unixservicehandler(object):' | |||
|
423 | 421 | serves for the current connection""" |
|
424 | 422 | return server(self.ui, repo, fin, fout) |
|
425 | 423 | |
|
426 | class _requesthandler(socketserver.BaseRequestHandler): | |
|
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): | |
|
424 | class unixforkingservice(object): | |
|
436 | 425 | """ |
|
437 | 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 | 430 | self.ui = ui |
|
441 | 431 | self.repo = repo |
|
442 | 432 | self.address = opts['address'] |
|
443 |
if not util.safehasattr(socket |
|
|
433 | if not util.safehasattr(socket, 'AF_UNIX'): | |
|
444 | 434 | raise error.Abort(_('unsupported platform')) |
|
445 | 435 | if not self.address: |
|
446 | 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 | 437 | self._servicehandler = handler or unixservicehandler(ui) |
|
469 | 438 | self._sock = None |
|
470 | 439 | self._oldsigchldhandler = None |
General Comments 0
You need to be logged in to leave comments.
Login now