compositor: Move `child_process_list` from global to `wet_compositor`.

Removes a global variable and makes it easier to avoid adding more
global variables in the next commit.

See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/652#note_975222

Signed-off-by: Alvarito050506 <donfrutosgomez@gmail.com>
dev
Alvarito050506 3 years ago committed by Álvaro Torralba
parent 7ae8a89a8b
commit 1f57a1f998
  1. 30
      compositor/main.c
  2. 3
      compositor/weston.h
  3. 2
      compositor/xwayland.c

@ -122,6 +122,7 @@ struct wet_compositor {
int (*simple_output_configure)(struct weston_output *output); int (*simple_output_configure)(struct weston_output *output);
bool init_failed; bool init_failed;
struct wl_list layoutput_list; /**< wet_layoutput::compositor_link */ struct wl_list layoutput_list; /**< wet_layoutput::compositor_link */
struct wl_list child_process_list;
}; };
static FILE *weston_logfile = NULL; static FILE *weston_logfile = NULL;
@ -344,22 +345,27 @@ protocol_log_fn(void *user_data,
free(logstr); free(logstr);
} }
static struct wl_list child_process_list; static struct wet_compositor *
to_wet_compositor(struct weston_compositor *compositor)
{
return weston_compositor_get_user_data(compositor);
}
static int static int
sigchld_handler(int signal_number, void *data) sigchld_handler(int signal_number, void *data)
{ {
struct weston_process *p; struct weston_process *p;
struct wet_compositor *wet = data;
int status; int status;
pid_t pid; pid_t pid;
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
wl_list_for_each(p, &child_process_list, link) { wl_list_for_each(p, &wet->child_process_list, link) {
if (p->pid == pid) if (p->pid == pid)
break; break;
} }
if (&p->link == &child_process_list) { if (&p->link == &wet->child_process_list) {
weston_log("unknown child process exited\n"); weston_log("unknown child process exited\n");
continue; continue;
} }
@ -454,15 +460,17 @@ weston_client_launch(struct weston_compositor *compositor,
proc->pid = pid; proc->pid = pid;
proc->cleanup = cleanup; proc->cleanup = cleanup;
weston_watch_process(proc); wet_watch_process(compositor, proc);
return client; return client;
} }
WL_EXPORT void WL_EXPORT void
weston_watch_process(struct weston_process *process) wet_watch_process(struct weston_compositor *compositor,
struct weston_process *process)
{ {
wl_list_insert(&child_process_list, &process->link); struct wet_compositor *wet = to_wet_compositor(compositor);
wl_list_insert(&wet->child_process_list, &process->link);
} }
struct process_info { struct process_info {
@ -536,12 +544,6 @@ log_uname(void)
usys.version, usys.machine); usys.version, usys.machine);
} }
static struct wet_compositor *
to_wet_compositor(struct weston_compositor *compositor)
{
return weston_compositor_get_user_data(compositor);
}
static struct wet_output_config * static struct wet_output_config *
wet_init_parsed_options(struct weston_compositor *ec) wet_init_parsed_options(struct weston_compositor *ec)
{ {
@ -3286,9 +3288,9 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
signals[2] = wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal, signals[2] = wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal,
display); display);
wl_list_init(&child_process_list); wl_list_init(&wet.child_process_list);
signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler, signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
NULL); &wet);
if (!signals[0] || !signals[1] || !signals[2] || !signals[3]) if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
goto out_signals; goto out_signals;

@ -56,7 +56,8 @@ struct wl_client *
weston_client_start(struct weston_compositor *compositor, const char *path); weston_client_start(struct weston_compositor *compositor, const char *path);
void void
weston_watch_process(struct weston_process *process); wet_watch_process(struct weston_compositor *compositor,
struct weston_process *process);
struct weston_config * struct weston_config *
wet_get_config(struct weston_compositor *compositor); wet_get_config(struct weston_compositor *compositor);

@ -154,7 +154,7 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd
wxw->wm_fd = wm[0]; wxw->wm_fd = wm[0];
wxw->process.pid = pid; wxw->process.pid = pid;
weston_watch_process(&wxw->process); wet_watch_process(wxw->compositor, &wxw->process);
break; break;
case -1: case -1:

Loading…
Cancel
Save