summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/ClickNLoad.py
diff options
context:
space:
mode:
authorGravatar Nitzo <nitzo2001@yahoo.com> 2016-01-08 21:20:51 +0100
committerGravatar Nitzo <nitzo2001@yahoo.com> 2016-01-08 21:20:51 +0100
commit0066bdbf0dde70b7eec8d0553cb72b023e4eee24 (patch)
tree7b81bf10caa055fec1d07a7f0eb0f5a188b0b6a3 /module/plugins/hooks/ClickNLoad.py
parent[ClickNLoad] Update (diff)
downloadpyload-0066bdbf0dde70b7eec8d0553cb72b023e4eee24.tar.xz
[ClickNLoad] Update
Diffstat (limited to 'module/plugins/hooks/ClickNLoad.py')
-rw-r--r--module/plugins/hooks/ClickNLoad.py41
1 files changed, 17 insertions, 24 deletions
diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py
index 81c630f93..4c72c7512 100644
--- a/module/plugins/hooks/ClickNLoad.py
+++ b/module/plugins/hooks/ClickNLoad.py
@@ -17,7 +17,7 @@ from module.plugins.internal.misc import forward, lock
class ClickNLoad(Addon):
__name__ = "ClickNLoad"
__type__ = "hook"
- __version__ = "0.56"
+ __version__ = "0.57"
__status__ = "testing"
__config__ = [("activated", "bool" , "Activated" , True ),
@@ -53,11 +53,23 @@ class ClickNLoad(Addon):
def deactivate(self):
- self._shutdown()
+ if self.server_running:
+ self.log_info(_("Shutting down proxy..."))
+ self.do_exit = True
- def exit(self):
- self._shutdown()
+ try:
+ wakeup_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ wakeup_socket.connect(("127.0.0.1" if any(_ip == self.cnl_ip for _ip in ("0.0.0.0", "")) else self.cnl_ip, self.cnl_port))
+ wakeup_socket.close()
+ except Exception:
+ pass
+
+ success_exit = self.exit_done.wait(10)
+ if success_exit:
+ self.log_debug(_("Server exited successfully"))
+ else:
+ self.log_warning(_("Server was not exited gracefully, shutdown forced"))
@lock
@@ -87,6 +99,7 @@ class ClickNLoad(Addon):
self.server_running = True
dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
dock_socket.bind((self.cnl_ip, self.cnl_port))
dock_socket.listen(5)
@@ -132,23 +145,3 @@ class ClickNLoad(Addon):
self.log_error(e)
time.sleep(240)
return self._server()
-
-
- def _shutdown(self):
- if self.server_running:
- self.log_info(_("Shutting down proxy..."))
-
- self.do_exit = True
-
- try:
- wakeup_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- wakeup_socket.connect(("127.0.0.1" if any(_ip == self.cnl_ip for _ip in ("0.0.0.0", "")) else self.cnl_ip, self.cnl_port))
- wakeup_socket.close()
- except Exception:
- pass
-
- success_exit = self.exit_done.wait(10)
- if success_exit:
- self.log_debug(_("Server exited successfully"))
- else:
- self.log_warning(_("Server was not exited gracefully, shutdown forced"))