##// END OF EJS Templates
inotify: raise correct error if server is already started in a deep repository...
Nicolas Dumazet -
r12650:fed4bb2c default
parent child Browse files
Show More
@@ -332,18 +332,21 b' class socketlistener(object):'
332 self.repowatcher = repowatcher
332 self.repowatcher = repowatcher
333 self.sock = socket.socket(socket.AF_UNIX)
333 self.sock = socket.socket(socket.AF_UNIX)
334 self.sockpath = join(root, '.hg/inotify.sock')
334 self.sockpath = join(root, '.hg/inotify.sock')
335 self.realsockpath = None
335
336 self.realsockpath = self.sockpath
337 if os.path.islink(self.sockpath):
338 if os.path.exists(self.sockpath):
339 self.realsockpath = os.readlink(self.sockpath)
340 else:
341 raise util.Abort('inotify-server: cannot start: '
342 '.hg/inotify.sock is a broken symlink')
336 try:
343 try:
337 self.sock.bind(self.sockpath)
344 self.sock.bind(self.realsockpath)
338 except socket.error, err:
345 except socket.error, err:
339 if err.args[0] == errno.EADDRINUSE:
346 if err.args[0] == errno.EADDRINUSE:
340 raise AlreadyStartedException(_('cannot start: socket is '
347 raise AlreadyStartedException(_('cannot start: socket is '
341 'already bound'))
348 'already bound'))
342 if err.args[0] == "AF_UNIX path too long":
349 if err.args[0] == "AF_UNIX path too long":
343 if os.path.islink(self.sockpath) and \
344 not os.path.exists(self.sockpath):
345 raise util.Abort('inotify-server: cannot start: '
346 '.hg/inotify.sock is a broken symlink')
347 tempdir = tempfile.mkdtemp(prefix="hg-inotify-")
350 tempdir = tempfile.mkdtemp(prefix="hg-inotify-")
348 self.realsockpath = os.path.join(tempdir, "inotify.sock")
351 self.realsockpath = os.path.join(tempdir, "inotify.sock")
349 try:
352 try:
@@ -26,4 +26,11 b' status'
26
26
27 $ hg status
27 $ hg status
28 ? hg.pid
28 ? hg.pid
29
30 if we try to start twice the server, make sure we get a correct error
31
32 $ hg inserve -d --pid-file=hg2.pid
33 abort: inotify-server: cannot start: socket is already bound
34 abort: child process failed to start
35 [255]
29 $ kill `cat hg.pid`
36 $ kill `cat hg.pid`
General Comments 0
You need to be logged in to leave comments. Login now