remoteloop: don't close a socket it didn't open
Closing the socket is the responsibility of whoever opened it. Fix this in the only user (qemu assembler) by using socket() in a `with` block, which closes the socket on exit.
This commit is contained in:
parent
c1dca86505
commit
3d3ffda5d8
2 changed files with 6 additions and 7 deletions
|
|
@ -111,8 +111,10 @@ def main(tree, output_dir, options, loop_client):
|
|||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_PASSCRED, 1)
|
||||
sock.connect("/run/osbuild/api/remoteloop")
|
||||
ret = main(args["tree"], args["output_dir"], args["options"], remoteloop.LoopClient(sock))
|
||||
|
||||
with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as sock:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_PASSCRED, 1)
|
||||
sock.connect("/run/osbuild/api/remoteloop")
|
||||
ret = main(args["tree"], args["output_dir"], args["options"], remoteloop.LoopClient(sock))
|
||||
|
||||
sys.exit(ret)
|
||||
|
|
|
|||
|
|
@ -112,9 +112,6 @@ class LoopClient:
|
|||
def __init__(self, sock):
|
||||
self.sock = sock
|
||||
|
||||
def __del__(self):
|
||||
self.sock.close()
|
||||
|
||||
def create_device(self, fd, dir_fd=None, offset=None, sizelimit=None):
|
||||
req = {}
|
||||
fds = array.array("i")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue