mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
remote: fix clear_memid
Use a separate variable to iterate the mem_ids. Clear some more fields.
This commit is contained in:
parent
8a4f3c546d
commit
cc53023fb9
2 changed files with 8 additions and 3 deletions
|
|
@ -72,6 +72,8 @@ struct pw_map_range {
|
||||||
uint32_t size; /** size to map */
|
uint32_t size; /** size to map */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PW_MAP_RANGE_INIT (struct pw_map_range){ 0, }
|
||||||
|
|
||||||
/** Calculate parameters to mmap() memory into \a range so that
|
/** Calculate parameters to mmap() memory into \a range so that
|
||||||
* \a size bytes at \a offset can be mapped with mmap(). */
|
* \a size bytes at \a offset can be mapped with mmap(). */
|
||||||
static inline void pw_map_range_init(struct pw_map_range *range,
|
static inline void pw_map_range_init(struct pw_map_range *range,
|
||||||
|
|
|
||||||
|
|
@ -584,9 +584,10 @@ static void *mem_map(struct node_data *data, struct mem_id *mid, uint32_t offset
|
||||||
}
|
}
|
||||||
static void mem_unmap(struct node_data *data, struct mem_id *mid)
|
static void mem_unmap(struct node_data *data, struct mem_id *mid)
|
||||||
{
|
{
|
||||||
if (mid->ptr) {
|
if (mid->ptr != NULL) {
|
||||||
if (munmap(mid->ptr, mid->map.size) < 0)
|
if (munmap(mid->ptr, mid->map.size) < 0)
|
||||||
pw_log_warn("failed to unmap: %m");
|
pw_log_warn("failed to unmap: %m");
|
||||||
|
mid->ptr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -595,12 +596,13 @@ static void clear_memid(struct node_data *data, struct mem_id *mid)
|
||||||
if (mid->fd != -1) {
|
if (mid->fd != -1) {
|
||||||
bool has_ref = false;
|
bool has_ref = false;
|
||||||
int fd;
|
int fd;
|
||||||
|
struct mem_id *m;
|
||||||
|
|
||||||
fd = mid->fd;
|
fd = mid->fd;
|
||||||
mid->fd = -1;
|
mid->fd = -1;
|
||||||
|
|
||||||
pw_array_for_each(mid, &data->mem_ids) {
|
pw_array_for_each(m, &data->mem_ids) {
|
||||||
if (mid->fd == fd) {
|
if (m->fd == fd) {
|
||||||
has_ref = true;
|
has_ref = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -687,6 +689,7 @@ static void client_node_add_mem(void *object,
|
||||||
m->fd = memfd;
|
m->fd = memfd;
|
||||||
m->flags = flags;
|
m->flags = flags;
|
||||||
m->ref = 0;
|
m->ref = 0;
|
||||||
|
m->map = PW_MAP_RANGE_INIT;
|
||||||
m->ptr = NULL;
|
m->ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue