kmscon: set uterm-seat data in seat-creation
If we want to be able to destroy seats from anywhere, not just uterm-monitor callbacks, we need to be able to reset the monitor-event seat-data so we no longer access the seat memory. Hence, move the seat-data set/reset logic into the actual seat creation/destroy functions. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
add239ee2c
commit
c4a1a33597
@ -52,6 +52,7 @@ struct app_video {
|
|||||||
struct app_seat {
|
struct app_seat {
|
||||||
struct shl_dlist list;
|
struct shl_dlist list;
|
||||||
struct kmscon_app *app;
|
struct kmscon_app *app;
|
||||||
|
struct uterm_monitor_seat *useat;
|
||||||
|
|
||||||
bool awake;
|
bool awake;
|
||||||
char *name;
|
char *name;
|
||||||
@ -143,7 +144,7 @@ static int app_seat_event(struct kmscon_seat *s, unsigned int event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int app_seat_new(struct kmscon_app *app, struct app_seat **out,
|
static int app_seat_new(struct kmscon_app *app, struct app_seat **out,
|
||||||
const char *sname)
|
const char *sname, struct uterm_monitor_seat *useat)
|
||||||
{
|
{
|
||||||
struct app_seat *seat;
|
struct app_seat *seat;
|
||||||
int ret;
|
int ret;
|
||||||
@ -177,6 +178,7 @@ static int app_seat_new(struct kmscon_app *app, struct app_seat **out,
|
|||||||
}
|
}
|
||||||
memset(seat, 0, sizeof(*seat));
|
memset(seat, 0, sizeof(*seat));
|
||||||
seat->app = app;
|
seat->app = app;
|
||||||
|
seat->useat = useat;
|
||||||
shl_dlist_init(&seat->videos);
|
shl_dlist_init(&seat->videos);
|
||||||
|
|
||||||
seat->name = strdup(sname);
|
seat->name = strdup(sname);
|
||||||
@ -204,6 +206,7 @@ static int app_seat_new(struct kmscon_app *app, struct app_seat **out,
|
|||||||
seat->conf_ctx = kmscon_seat_get_conf(seat->seat);
|
seat->conf_ctx = kmscon_seat_get_conf(seat->seat);
|
||||||
seat->conf = conf_ctx_get_mem(seat->conf_ctx);
|
seat->conf = conf_ctx_get_mem(seat->conf_ctx);
|
||||||
|
|
||||||
|
uterm_monitor_set_seat_data(seat->useat, seat);
|
||||||
shl_dlist_link(&app->seats, &seat->list);
|
shl_dlist_link(&app->seats, &seat->list);
|
||||||
++app->running_seats;
|
++app->running_seats;
|
||||||
*out = seat;
|
*out = seat;
|
||||||
@ -221,6 +224,7 @@ static void app_seat_free(struct app_seat *seat)
|
|||||||
log_debug("free seat %s", seat->name);
|
log_debug("free seat %s", seat->name);
|
||||||
|
|
||||||
shl_dlist_unlink(&seat->list);
|
shl_dlist_unlink(&seat->list);
|
||||||
|
uterm_monitor_set_seat_data(seat->useat, NULL);
|
||||||
kmscon_seat_free(seat->seat);
|
kmscon_seat_free(seat->seat);
|
||||||
free(seat->name);
|
free(seat->name);
|
||||||
free(seat);
|
free(seat);
|
||||||
@ -400,10 +404,9 @@ static void app_monitor_event(struct uterm_monitor *mon,
|
|||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case UTERM_MONITOR_NEW_SEAT:
|
case UTERM_MONITOR_NEW_SEAT:
|
||||||
ret = app_seat_new(app, &seat, ev->seat_name);
|
ret = app_seat_new(app, &seat, ev->seat_name, ev->seat);
|
||||||
if (ret)
|
if (ret)
|
||||||
return;
|
return;
|
||||||
uterm_monitor_set_seat_data(ev->seat, seat);
|
|
||||||
break;
|
break;
|
||||||
case UTERM_MONITOR_FREE_SEAT:
|
case UTERM_MONITOR_FREE_SEAT:
|
||||||
if (ev->seat_data)
|
if (ev->seat_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user