From aa5f69b203d9b41dd57b9d9768e7bbcf67434df1 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 13 Nov 2009 01:07:36 +0000 Subject: [PATCH] Fix #1071 issue where Deluge will fail to start if there is a stale ipc lockfile --- ChangeLog | 1 + deluge/ui/gtkui/ipcinterface.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bf51e3152..3d046eba6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ * Fix adding torrents from the Queued Torrents dialog * Fix disabling/enabling plugins after switching daemons * Reduce height of Add Torrent Dialog by ~80 pixels + * Fix issue where Deluge will fail to start if there is a stale ipc lockfile ==== Web ==== * Fix installing the deluge-web manpage diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py index 2ee48fd21..522cf9c16 100644 --- a/deluge/ui/gtkui/ipcinterface.py +++ b/deluge/ui/gtkui/ipcinterface.py @@ -35,7 +35,7 @@ import sys -import os.path +import os import base64 import deluge.rencode @@ -104,6 +104,19 @@ class IPCInterface(component.Component): reactor.run() sys.exit(0) 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: self.factory = Factory() self.factory.protocol = IPCProtocolServer