summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/prserv
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2015-09-15 14:59:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-24 17:55:05 +0100
commit5a51fb28dbdfcae8ceb503a5290532dd38aeb09f (patch)
tree8ffa8953ccba2d9feaf0c6103307fe17e9d650f6 /bitbake/lib/prserv
parent2687b245c25e81cd4a3ab77d49bbbfc93af0f59d (diff)
downloadpoky-5a51fb28dbdfcae8ceb503a5290532dd38aeb09f.tar.gz
bitbake: prserv/serv: Start/Stop daemon using ip instead of host
In cases where hostname is given instead of an IP (i.e. localhost instead of 127.0.0.1) when stopping the server with bitbake-prserv --stop, the server shows a misleading message indicating that the daemon was not found, where it is actually stopped. This patch converts host to IP values before starting/stopping the daemon, so it will always work on IP, not on hostnames, avoiding problems like the latter. [YOCTO #8258] (Bitbake rev: bd6398e967c234e89d773f509512ebf460fa76ff) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv')
-rw-r--r--bitbake/lib/prserv/serv.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 5c0ffb9925..3cb2e03dad 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -3,6 +3,7 @@ import signal, time
3from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler 3from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
4import threading 4import threading
5import Queue 5import Queue
6import socket
6 7
7try: 8try:
8 import sqlite3 9 import sqlite3
@@ -37,7 +38,6 @@ singleton = None
37class PRServer(SimpleXMLRPCServer): 38class PRServer(SimpleXMLRPCServer):
38 def __init__(self, dbfile, logfile, interface, daemon=True): 39 def __init__(self, dbfile, logfile, interface, daemon=True):
39 ''' constructor ''' 40 ''' constructor '''
40 import socket
41 try: 41 try:
42 SimpleXMLRPCServer.__init__(self, interface, 42 SimpleXMLRPCServer.__init__(self, interface,
43 logRequests=False, allow_none=True) 43 logRequests=False, allow_none=True)
@@ -289,7 +289,8 @@ class PRServerConnection(object):
289 return self.host, self.port 289 return self.host, self.port
290 290
291def start_daemon(dbfile, host, port, logfile): 291def start_daemon(dbfile, host, port, logfile):
292 pidfile = PIDPREFIX % (host, port) 292 ip = socket.gethostbyname(host)
293 pidfile = PIDPREFIX % (ip, port)
293 try: 294 try:
294 pf = file(pidfile,'r') 295 pf = file(pidfile,'r')
295 pid = int(pf.readline().strip()) 296 pid = int(pf.readline().strip())
@@ -302,12 +303,14 @@ def start_daemon(dbfile, host, port, logfile):
302 % pidfile) 303 % pidfile)
303 return 1 304 return 1
304 305
305 server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (host,port)) 306 server = PRServer(os.path.abspath(dbfile), os.path.abspath(logfile), (ip,port))
306 server.start() 307 server.start()
308
307 return 0 309 return 0
308 310
309def stop_daemon(host, port): 311def stop_daemon(host, port):
310 pidfile = PIDPREFIX % (host, port) 312 ip = socket.gethostbyname(host)
313 pidfile = PIDPREFIX % (ip, port)
311 try: 314 try:
312 pf = file(pidfile,'r') 315 pf = file(pidfile,'r')
313 pid = int(pf.readline().strip()) 316 pid = int(pf.readline().strip())
@@ -320,7 +323,7 @@ def stop_daemon(host, port):
320 % pidfile) 323 % pidfile)
321 324
322 try: 325 try:
323 PRServerConnection(host, port).terminate() 326 PRServerConnection(ip, port).terminate()
324 except: 327 except:
325 logger.critical("Stop PRService %s:%d failed" % (host,port)) 328 logger.critical("Stop PRService %s:%d failed" % (host,port))
326 329