Fix #1071 issue where Deluge will fail to start if there is a stale ipc lockfile

This commit is contained in:
Andrew Resch 2009-11-13 01:07:36 +00:00
parent f98c3adf2f
commit bdba9cd00a
1 changed files with 15 additions and 1 deletions

View File

@ -35,7 +35,7 @@
import sys import sys
import os.path import os
import base64 import base64
import deluge.rencode import deluge.rencode
@ -104,6 +104,20 @@ class IPCInterface(component.Component):
reactor.run() reactor.run()
sys.exit(0) sys.exit(0)
else: else:
lockfile = socket + ".lock"
log.debug("Checking if lockfile exists: %s", lockfile)
if os.path.lexists(lockfile):
try:
os.kill(int(os.readlink(lockfile)), 0)
except OSError:
log.debug("Removing lockfile since it's stale.")
try:
os.remove(lockfile)
os.remove(socket)
except Exception, e:
log.error("Problem deleting lockfile or socket file!")
log.exception(e)
try: try:
self.factory = Factory() self.factory = Factory()
self.factory.protocol = IPCProtocolServer self.factory.protocol = IPCProtocolServer