[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Improve error handling for the HTTPServer if a port is already occupied.



commit f6026516b7a4e80d7318ec783e2d56bb1063109c
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Tue Nov 19 08:01:50 2013 +0000

    Improve error handling for the HTTPServer if a port is already occupied.
---
 lib/bridgedb/HTTPServer.py |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index ca850d5..fe4e095 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -15,6 +15,7 @@ import time
 import os
 
 from twisted.internet import reactor
+from twisted.internet.error import CannotListenError
 import twisted.web.resource
 from twisted.web.server import Site
 from twisted.web import static
@@ -274,7 +275,10 @@ def addWebServer(cfg, dist, sched):
 
     if cfg.HTTP_UNENCRYPTED_PORT:
         ip = cfg.HTTP_UNENCRYPTED_BIND_IP or ""
-        reactor.listenTCP(cfg.HTTP_UNENCRYPTED_PORT, site, interface=ip)
+        try:
+            reactor.listenTCP(cfg.HTTP_UNENCRYPTED_PORT, site, interface=ip)
+        except CannotListenError as error:
+            raise SystemExit(error)
 
     if cfg.HTTPS_PORT:
         from twisted.internet.ssl import DefaultOpenSSLContextFactory
@@ -282,7 +286,10 @@ def addWebServer(cfg, dist, sched):
         ip = cfg.HTTPS_BIND_IP or ""
         factory = DefaultOpenSSLContextFactory(cfg.HTTPS_KEY_FILE,
                                                cfg.HTTPS_CERT_FILE)
-        reactor.listenSSL(cfg.HTTPS_PORT, site, factory, interface=ip)
+        try:
+            reactor.listenSSL(cfg.HTTPS_PORT, site, factory, interface=ip)
+        except CannotListenError as error:
+            raise SystemExit(error)
 
     return site
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits