summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-13 01:45:31 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-13 01:45:31 +0100
commit7e5e88778c2dd4fac088cffbd2fba4384dde8582 (patch)
tree459056c07e276edb36b61a5630d2b0cd6f85e036 /module
parent[SimpleCrypter] getLinks auto-complete links (diff)
downloadpyload-7e5e88778c2dd4fac088cffbd2fba4384dde8582.tar.xz
[ClickAndLoad] Fix error "Port already in use"
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hooks/ClickAndLoad.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index 8ef31ec1e..222310c25 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -3,6 +3,7 @@
import socket
from threading import Thread, Lock
+from time import sleep
from module.plugins.Hook import Hook, threaded
@@ -20,7 +21,7 @@ def forward(source, destination):
class ClickAndLoad(Hook):
__name__ = "ClickAndLoad"
__type__ = "hook"
- __version__ = "0.25"
+ __version__ = "0.26"
__config__ = [("activated", "bool", "Activated" , True ),
("port" , "int" , "Port" , 9666 ),
@@ -54,6 +55,8 @@ class ClickAndLoad(Hook):
def server(self, ip, webport, cnlport):
try:
dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
dock_socket.bind((ip, cnlport))
dock_socket.listen(5)
@@ -65,17 +68,8 @@ class ClickAndLoad(Hook):
hookManager.startThread(forward, client_socket, server_socket)
except socket.error, e:
- if hasattr(e, "errno"):
- errno = e.errno
- else:
- errno = e.args[0]
-
- if errno == 98:
- self.logWarning(_("Port %s already in use") % cnlport)
- else:
- self.logError(e)
- self.server(ip, webport, cnlport)
-
- except Exception, e:
self.logError(e)
self.server(ip, webport, cnlport)
+
+ finally:
+ dock_socket.close()