summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-24 16:49:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-25 18:14:53 +0100
commita1c956ab4cae61ab3640d0455887645940e85ab6 (patch)
tree10daca4ac582713e7d6a98cb9ee49dae584d97b7
parent0bcc00ac517bdb9a8035397fcac0a402fe1aad13 (diff)
downloadpoky-a1c956ab4cae61ab3640d0455887645940e85ab6.tar.gz
bitbake: server/process: Move the socket code to server process only
The sock object isn't used client side so we can just created it in the server process and save passing around the fd/object. (Bitbake rev: ee5d2c92dcce89ccb701e028ffc6419eb315f5ce) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/server/process.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index b037e0fb6c..8f5abb32bf 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -402,27 +402,11 @@ class BitBakeServer(object):
402 self.bitbake_lock = lock 402 self.bitbake_lock = lock
403 self.readypipe, self.readypipein = os.pipe() 403 self.readypipe, self.readypipein = os.pipe()
404 404
405 # Create server control socket
406 if os.path.exists(sockname):
407 os.unlink(sockname)
408
409 # Place the log in the builddirectory alongside the lock file 405 # Place the log in the builddirectory alongside the lock file
410 logfile = os.path.join(os.path.dirname(self.bitbake_lock.name), "bitbake-cookerdaemon.log") 406 logfile = os.path.join(os.path.dirname(self.bitbake_lock.name), "bitbake-cookerdaemon.log")
411 407
412 self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
413 # AF_UNIX has path length issues so chdir here to workaround
414 cwd = os.getcwd()
415 try:
416 os.chdir(os.path.dirname(sockname))
417 self.sock.bind(os.path.basename(sockname))
418 finally:
419 os.chdir(cwd)
420 self.sock.listen(1)
421
422 os.set_inheritable(self.sock.fileno(), True)
423 startdatetime = datetime.datetime.now() 408 startdatetime = datetime.datetime.now()
424 bb.daemonize.createDaemon(self._startServer, logfile) 409 bb.daemonize.createDaemon(self._startServer, logfile)
425 self.sock.close()
426 self.bitbake_lock.close() 410 self.bitbake_lock.close()
427 os.close(self.readypipein) 411 os.close(self.readypipein)
428 412
@@ -478,7 +462,21 @@ class BitBakeServer(object):
478 sys.stdout.flush() 462 sys.stdout.flush()
479 463
480 try: 464 try:
481 server = ProcessServer(self.bitbake_lock, self.sock, self.sockname, self.configuration.server_timeout, self.configuration.xmlrpcinterface) 465 # Create server control socket
466 if os.path.exists(self.sockname):
467 os.unlink(self.sockname)
468
469 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
470 # AF_UNIX has path length issues so chdir here to workaround
471 cwd = os.getcwd()
472 try:
473 os.chdir(os.path.dirname(self.sockname))
474 sock.bind(os.path.basename(self.sockname))
475 finally:
476 os.chdir(cwd)
477 sock.listen(1)
478
479 server = ProcessServer(self.bitbake_lock, sock, self.sockname, self.configuration.server_timeout, self.configuration.xmlrpcinterface)
482 os.close(self.readypipe) 480 os.close(self.readypipe)
483 writer = ConnectionWriter(self.readypipein) 481 writer = ConnectionWriter(self.readypipein)
484 try: 482 try: