mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-12 05:34:41 -04:00
connection: Dont put fds in the connection until we send the closure
This commit is contained in:
parent
9d37682db3
commit
0d6dea17b4
1 changed files with 30 additions and 5 deletions
|
|
@ -533,11 +533,6 @@ wl_connection_vmarshal(struct wl_connection *connection,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
*fd_ptr = dup_fd;
|
*fd_ptr = dup_fd;
|
||||||
if (wl_connection_put_fd(connection, dup_fd)) {
|
|
||||||
printf("request could not be mashaled: "
|
|
||||||
"can't send file descriptor");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unhandled format code: '%c'\n",
|
fprintf(stderr, "unhandled format code: '%c'\n",
|
||||||
|
|
@ -767,11 +762,38 @@ wl_closure_invoke(struct wl_closure *closure,
|
||||||
ffi_call(&closure->cif, func, &result, closure->args);
|
ffi_call(&closure->cif, func, &result, closure->args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
copy_fds_to_connection(struct wl_closure *closure,
|
||||||
|
struct wl_connection *connection)
|
||||||
|
{
|
||||||
|
const struct wl_message *message = closure->message;
|
||||||
|
uint32_t i, count;
|
||||||
|
int *fd;
|
||||||
|
|
||||||
|
count = strlen(message->signature) + 2;
|
||||||
|
for (i = 2; i < count; i++) {
|
||||||
|
if (message->signature[i - 2] != 'h')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fd = closure->args[i];
|
||||||
|
if (wl_connection_put_fd(connection, *fd)) {
|
||||||
|
fprintf(stderr, "request could not be marshaled: "
|
||||||
|
"can't send file descriptor");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
|
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
|
if (copy_fds_to_connection(closure, connection))
|
||||||
|
return -1;
|
||||||
|
|
||||||
size = closure->start[1] >> 16;
|
size = closure->start[1] >> 16;
|
||||||
|
|
||||||
return wl_connection_write(connection, closure->start, size);
|
return wl_connection_write(connection, closure->start, size);
|
||||||
|
|
@ -782,6 +804,9 @@ wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection)
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
|
if (copy_fds_to_connection(closure, connection))
|
||||||
|
return -1;
|
||||||
|
|
||||||
size = closure->start[1] >> 16;
|
size = closure->start[1] >> 16;
|
||||||
|
|
||||||
return wl_connection_queue(connection, closure->start, size);
|
return wl_connection_queue(connection, closure->start, size);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue