#2451 closed defect (worksforme)
platform/xposix/appindicator_tray.py leaks a file descriptor in set_icon_from_data
Reported by: | aerusso | Owned by: | aerusso |
---|---|---|---|
Priority: | major | Milestone: | 4.0 |
Component: | client | Version: | 3.0.x |
Keywords: | file descriptor leak | Cc: |
Description
When a new temporary file is created,
self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir)[1]
a file is opened (and its file descriptor is assigned to the [0]
element of that tuple). That file is actually immediately clobbered---it is not used except to avoid races.
That file descriptor can just be immediately closed:
fd,self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir) os.close(fd)
This works (on Linux) and resolves the leak. It resolves an issue that looks like an unresponsive client (in my case right clicking just showed a blank box, with the colored border expected around windows). It failed with an error message like unable to create file descriptor or unable to open file (I've forgotten the exact wording).
Change History (6)
comment:1 Changed 17 months ago by
Owner: | changed from Antoine Martin to aerusso |
---|
comment:2 Changed 17 months ago by
Do you think there is any merit in handling, e.g., out of space errors?
fd, self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir) try: log("set_icon_from_data%s using temporary file %s", ("%s pixels" % len(pixels), has_alpha, w, h, rowstride), self.tmp_filename) os.write(fd, png_data) finally: os.close(fd) os.fchmod(fd, 0o644)
(Beware untested code.)
comment:3 Changed 17 months ago by
Do you think there is any merit in handling, e.g., out of space errors?
r24165 should handle any errors in the section handling IO.
comment:4 Changed 16 months ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:5 Changed 16 months ago by
Milestone: | 3.1 → 4.0 |
---|
comment:6 Changed 5 weeks ago by
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2451
Thanks, applied in r24161.
How about r24162 instead?