}
static void
-close_fds(struct wl_buffer *buffer)
+close_fds(struct wl_buffer *buffer, int max)
{
- int fds[MAX_FDS_OUT], i, count;
+ int32_t fds[sizeof(buffer->data) / sizeof(int32_t)], i, count;
size_t size;
size = buffer->head - buffer->tail;
wl_buffer_copy(buffer, fds, size);
count = size / sizeof fds[0];
+ if (max > 0 && max < count)
+ count = max;
for (i = 0; i < count; i++)
close(fds[i]);
buffer->tail += size;
void
wl_connection_destroy(struct wl_connection *connection)
{
- close_fds(&connection->fds_out);
+ close_fds(&connection->fds_out, -1);
close(connection->fd);
free(connection);
}
if (len == -1)
return -1;
- close_fds(&connection->fds_out);
+ close_fds(&connection->fds_out, MAX_FDS_OUT);
connection->out.tail += len;
}