diff options
author | Konrad Scherer <Konrad.Scherer@windriver.com> | 2014-09-24 09:06:42 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-29 12:08:17 +0100 |
commit | fae5914030bcf4c061c22fc61034c40c87b7121a (patch) | |
tree | b63bcd85452202cb2f9cd74e6d12f9435afe5577 /lib/prserv | |
parent | 73bf120062fc00c7e26dc4e77a7d140658d89daf (diff) | |
download | bitbake-contrib-fae5914030bcf4c061c22fc61034c40c87b7121a.tar.gz |
prserv/serv: Improve error message when prserver cannot bind to supplied host address
If localhost resolves to a remote address (due to a misconfigured network),
starting the pr server will fail without useful information.
To reproduce, add '<bogus ip> localhost' to /etc/hosts and run
'bitbake -p'. The error message will be:
ERROR: Timeout while attempting to communicate with bitbake server
ERROR: Could not connect to server False:
Running 'bitbake-prserv --host=localhost --port=0 --start' will fail with:
error: [Errno 99] Cannot assign requested address
Since these errors does not show the IP address of the attempted socket
binding, this results in a lot of wasted time looking at firewall rules, etc.
This patch results in the following error message if the socket binding fails:
PR Server unable to bind to <bogus ip>:0
Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/prserv')
-rw-r--r-- | lib/prserv/serv.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py index 1e170cea0..1b08d5913 100644 --- a/lib/prserv/serv.py +++ b/lib/prserv/serv.py @@ -38,8 +38,17 @@ singleton = None class PRServer(SimpleXMLRPCServer): def __init__(self, dbfile, logfile, interface, daemon=True): ''' constructor ''' - SimpleXMLRPCServer.__init__(self, interface, - logRequests=False, allow_none=True) + import socket + try: + SimpleXMLRPCServer.__init__(self, interface, + logRequests=False, allow_none=True) + except socket.error: + ip=socket.gethostbyname(interface[0]) + port=interface[1] + msg="PR Server unable to bind to %s:%s\n" % (ip, port) + sys.stderr.write(msg) + raise PRServiceConfigError + self.dbfile=dbfile self.daemon=daemon self.logfile=logfile |