mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/swapchain: Close and remaining open FDs
This commit is contained in:
parent
753b910b5a
commit
09baeb91bc
2
doc/changes/compositor/mr.359.2.md
Normal file
2
doc/changes/compositor/mr.359.2.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
swapchain: Close any FDs that are still valid, for instance the ipc server
|
||||||
|
copies the FDs to the client.
|
|
@ -7,13 +7,14 @@
|
||||||
* @ingroup comp_main
|
* @ingroup comp_main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "util/u_misc.h"
|
#include "util/u_misc.h"
|
||||||
|
|
||||||
#include "main/comp_compositor.h"
|
#include "main/comp_compositor.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
swapchain_destroy(struct xrt_swapchain *xsc)
|
swapchain_destroy(struct xrt_swapchain *xsc)
|
||||||
|
@ -243,6 +244,11 @@ comp_swapchain_create(struct xrt_compositor *xc,
|
||||||
|
|
||||||
COMP_DEBUG(c, "CREATE %p %dx%d", (void *)sc, width, height);
|
COMP_DEBUG(c, "CREATE %p %dx%d", (void *)sc, width, height);
|
||||||
|
|
||||||
|
// Make sure the fds are invalid.
|
||||||
|
for (uint32_t i = 0; i < ARRAY_SIZE(sc->base.images); i++) {
|
||||||
|
sc->base.images[i].fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_images; i++) {
|
for (uint32_t i = 0; i < num_images; i++) {
|
||||||
ret =
|
ret =
|
||||||
create_image_fd(c, bits, format, width, height, array_size,
|
create_image_fd(c, bits, format, width, height, array_size,
|
||||||
|
@ -361,5 +367,14 @@ comp_swapchain_really_destroy(struct comp_swapchain *sc)
|
||||||
&sc->images[i]);
|
&sc->images[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < sc->base.base.num_images; i++) {
|
||||||
|
if (sc->base.images[i].fd < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(sc->base.images[i].fd);
|
||||||
|
sc->base.images[i].fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
free(sc);
|
free(sc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue