[svn] commit: r2540 - in /trunk: ./ ChangeLog src/bin/cmdctl/TODO src/bin/cmdctl/cmdctl.py.in src/bin/cmdctl/tests/cmdctl_test.py src/bin/xfrin/ src/lib/cc/ src/lib/datasrc/ src/lib/dns/ src/lib/dns/rdata/generic/rrsig_46.cc src/lib/dns/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 20 07:13:37 UTC 2010
Author: zhanglikun
Date: Tue Jul 20 07:13:37 2010
New Revision: 2540
Log:
Merge branch 277(cmdctl needs nicer warning if address already in use) into trunk.
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/src/bin/cmdctl/TODO
trunk/src/bin/cmdctl/cmdctl.py.in
trunk/src/bin/cmdctl/tests/cmdctl_test.py
trunk/src/bin/xfrin/ (props changed)
trunk/src/lib/cc/ (props changed)
trunk/src/lib/datasrc/ (props changed)
trunk/src/lib/dns/ (props changed)
trunk/src/lib/dns/rdata/generic/rrsig_46.cc (props changed)
trunk/src/lib/dns/tests/ (props changed)
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Tue Jul 20 07:13:37 2010
@@ -1,3 +1,7 @@
+ 77. [func] zhanglikun
+ Make error message be more friendly when running cmdctl and it's
+ already running(listening on same port)(Trac #277, r2540)
+
76. [bug] jelte
Fixed a bug in the handling of 'remote' config modules (i.e.
modules that peek at the configuration of other modules), where
Modified: trunk/src/bin/cmdctl/TODO
==============================================================================
--- trunk/src/bin/cmdctl/TODO (original)
+++ trunk/src/bin/cmdctl/TODO Tue Jul 20 07:13:37 2010
@@ -3,4 +3,5 @@
. Add check for the content of key/certificate file
(when cmdctl starts or is configured by bindctl).
. Use only one msgq/session to communicate with other modules?
-
+. Add more test cases, especially about the cases where CmdctlException
+ is raised
Modified: trunk/src/bin/cmdctl/cmdctl.py.in
==============================================================================
--- trunk/src/bin/cmdctl/cmdctl.py.in (original)
+++ trunk/src/bin/cmdctl/cmdctl.py.in Tue Jul 20 07:13:37 2010
@@ -441,7 +441,11 @@
CommandControlClass,
idle_timeout = 1200, verbose = False):
'''idle_timeout: the max idle time for login'''
- http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
+ try:
+ http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
+ except socket.error as err:
+ raise CmdctlException("Error creating server, because: %s \n" % str(err))
+
self.user_sessions = {}
self.idle_timeout = idle_timeout
self.cmdctl = CommandControlClass(self, verbose)
@@ -587,20 +591,23 @@
help="display more about what is going on")
if __name__ == '__main__':
+ set_signal_handler()
+ parser = OptionParser(version = __version__)
+ set_cmd_options(parser)
+ (options, args) = parser.parse_args()
+ result = 1 # in case of failure
try:
- set_signal_handler()
- parser = OptionParser(version = __version__)
- set_cmd_options(parser)
- (options, args) = parser.parse_args()
run(options.addr, options.port, options.idle_timeout, options.verbose)
- except isc.cc.SessionError as se:
+ result = 0
+ except isc.cc.SessionError as err:
sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, "
- "is the command channel daemon running?\n")
+ "is the command channel daemon running?\n")
except KeyboardInterrupt:
- sys.stderr.write("[b10-cmdctl] exit http server\n")
+ sys.stderr.write("[b10-cmdctl] exit from Cmdctl\n")
+ except CmdctlException as err:
+ sys.stderr.write("[b10-cmdctl] " + str(err) + "\n")
if httpd:
httpd.shutdown()
-
-
+ sys.exit(result)
Modified: trunk/src/bin/cmdctl/tests/cmdctl_test.py
==============================================================================
--- trunk/src/bin/cmdctl/tests/cmdctl_test.py (original)
+++ trunk/src/bin/cmdctl/tests/cmdctl_test.py Tue Jul 20 07:13:37 2010
@@ -383,13 +383,31 @@
class TestSecureHTTPServer(unittest.TestCase):
def setUp(self):
self.old_stdout = sys.stdout
+ self.old_stderr = sys.stderr
sys.stdout = open(os.devnull, 'w')
+ sys.stderr = sys.stdout
self.server = MySecureHTTPServer(('localhost', 8080),
MySecureHTTPRequestHandler,
MyCommandControl, verbose=True)
def tearDown(self):
sys.stdout = self.old_stdout
+ sys.stderr = self.old_stderr
+
+ def test_addr_in_use(self):
+ server_one = None
+ try:
+ server_one = SecureHTTPServer(('localhost', 53531),
+ MySecureHTTPRequestHandler,
+ MyCommandControl)
+ except CmdctlException:
+ pass
+ else:
+ self.assertRaises(CmdctlException, SecureHTTPServer,
+ ('localhost', 53531),
+ MySecureHTTPRequestHandler, MyCommandControl)
+ if server_one:
+ server_one.server_close()
def test_create_user_info(self):
self.server._create_user_info('/local/not-exist')
More information about the bind10-changes
mailing list