mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-05 13:29:50 -05:00
server: Disconnect client on error
This commit is contained in:
parent
47b446987d
commit
58b9c1bf17
2 changed files with 17 additions and 11 deletions
|
|
@ -62,6 +62,7 @@ struct wl_client {
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_map objects;
|
struct wl_map objects;
|
||||||
|
int error;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_display {
|
struct wl_display {
|
||||||
|
|
@ -118,6 +119,7 @@ wl_client_post_error(struct wl_client *client, struct wl_object *object,
|
||||||
vsnprintf(buffer, sizeof buffer, msg, ap);
|
vsnprintf(buffer, sizeof buffer, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
client->error = 1;
|
||||||
wl_resource_post_event(client->display_resource,
|
wl_resource_post_event(client->display_resource,
|
||||||
WL_DISPLAY_ERROR, object, code, buffer);
|
WL_DISPLAY_ERROR, object, code, buffer);
|
||||||
}
|
}
|
||||||
|
|
@ -158,9 +160,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
wl_client_post_error(client, &resource->object,
|
wl_client_post_error(client, &resource->object,
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||||
"invalid object %d", p[0]);
|
"invalid object %d", p[0]);
|
||||||
wl_connection_consume(connection, size);
|
break;
|
||||||
len -= size;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object = &resource->object;
|
object = &resource->object;
|
||||||
|
|
@ -170,9 +170,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
"invalid method %d, object %s@%d",
|
"invalid method %d, object %s@%d",
|
||||||
object->interface->name,
|
object->interface->name,
|
||||||
object->id, opcode);
|
object->id, opcode);
|
||||||
wl_connection_consume(connection, size);
|
break;
|
||||||
len -= size;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message = &object->interface->methods[opcode];
|
message = &object->interface->methods[opcode];
|
||||||
|
|
@ -187,13 +185,12 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
object->interface->name,
|
object->interface->name,
|
||||||
object->id,
|
object->id,
|
||||||
message->name);
|
message->name);
|
||||||
continue;
|
break;
|
||||||
} else if (closure == NULL && errno == ENOMEM) {
|
} else if (closure == NULL && errno == ENOMEM) {
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (wl_debug)
|
if (wl_debug)
|
||||||
wl_closure_print(closure, object, false);
|
wl_closure_print(closure, object, false);
|
||||||
|
|
||||||
|
|
@ -201,8 +198,14 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
|
||||||
object->implementation[opcode], client);
|
object->implementation[opcode], client);
|
||||||
|
|
||||||
wl_closure_destroy(closure);
|
wl_closure_destroy(closure);
|
||||||
|
|
||||||
|
if (client->error)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (client->error)
|
||||||
|
wl_client_destroy(client);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -321,6 +324,7 @@ wl_client_destroy(struct wl_client *client)
|
||||||
|
|
||||||
printf("disconnect from client %p\n", client);
|
printf("disconnect from client %p\n", client);
|
||||||
|
|
||||||
|
wl_client_flush(client);
|
||||||
wl_map_for_each(&client->objects, destroy_resource, &time);
|
wl_map_for_each(&client->objects, destroy_resource, &time);
|
||||||
wl_map_release(&client->objects);
|
wl_map_release(&client->objects);
|
||||||
wl_event_source_remove(client->source);
|
wl_event_source_remove(client->source);
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,10 @@ struct wl_selection {
|
||||||
struct wl_listener selection_focus_listener;
|
struct wl_listener selection_focus_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void wl_resource_post_event(struct wl_resource *resource,
|
||||||
wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...);
|
uint32_t opcode, ...);
|
||||||
|
void wl_resource_post_error(struct wl_resource *resource,
|
||||||
|
uint32_t code, const char *msg, ...);
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_display_set_compositor(struct wl_display *display,
|
wl_display_set_compositor(struct wl_display *display,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue