~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: Andrew Bennetts
  • Date: 2011-03-18 01:12:17 UTC
  • mto: (5609.24.3 2.3)
  • mto: This revision was merged to the branch mainline in revision 5732.
  • Revision ID: andrew.bennetts@canonical.com-20110318011217-h1206xizh4kj1ldw
Alternative fix: cache the result of get_master_branch for the lifetime of the branch lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import errno
20
20
import os.path
 
21
import select
21
22
import socket
22
23
import sys
23
24
import threading
24
25
 
25
 
from bzrlib.hooks import Hooks
 
26
from bzrlib.hooks import HookPoint, Hooks
26
27
from bzrlib import (
27
28
    errors,
28
29
    trace,
103
104
        # The URL that a commit done on the same machine as the server will
104
105
        # have within the servers space. (e.g. file:///home/user/source)
105
106
        # The URL that will be given to other hooks in the same process -
106
 
        # the URL of the backing transport itself. (e.g. filtered-36195:///)
 
107
        # the URL of the backing transport itself. (e.g. chroot+:///)
107
108
        # We need all three because:
108
109
        #  * other machines see the first
109
110
        #  * local commits on this machine should be able to be mapped to
176
177
 
177
178
    def get_url(self):
178
179
        """Return the url of the server"""
179
 
        return "bzr://%s:%s/" % (self._sockname[0], self._sockname[1])
 
180
        return "bzr://%s:%d/" % self._sockname
180
181
 
181
182
    def serve_conn(self, conn, thread_name_suffix):
182
183
        # For WIN32, where the timeout value from the listening socket
239
240
        These are all empty initially, because by default nothing should get
240
241
        notified.
241
242
        """
242
 
        Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks")
243
 
        self.add_hook('server_started',
 
243
        Hooks.__init__(self)
 
244
        self.create_hook(HookPoint('server_started',
244
245
            "Called by the bzr server when it starts serving a directory. "
245
246
            "server_started is called with (backing urls, public url), "
246
247
            "where backing_url is a list of URLs giving the "
247
248
            "server-specific directory locations, and public_url is the "
248
 
            "public URL for the directory being served.", (0, 16))
249
 
        self.add_hook('server_started_ex',
 
249
            "public URL for the directory being served.", (0, 16), None))
 
250
        self.create_hook(HookPoint('server_started_ex',
250
251
            "Called by the bzr server when it starts serving a directory. "
251
252
            "server_started is called with (backing_urls, server_obj).",
252
 
            (1, 17))
253
 
        self.add_hook('server_stopped',
 
253
            (1, 17), None))
 
254
        self.create_hook(HookPoint('server_stopped',
254
255
            "Called by the bzr server when it stops serving a directory. "
255
256
            "server_stopped is called with the same parameters as the "
256
 
            "server_started hook: (backing_urls, public_url).", (0, 16))
 
257
            "server_started hook: (backing_urls, public_url).", (0, 16), None))
257
258
 
258
259
SmartTCPServer.hooks = SmartServerHooks()
259
260