[PATCH weston] Fix a crash when opening two terminal windows and closing the first one.

Kristian Høgsberg hoegsberg at gmail.com
Fri Nov 30 11:13:18 PST 2012


On Thu, Nov 29, 2012 at 12:27:09AM -0800, Dima Ryazanov wrote:
> To reproduce, launch the terminal, open a second window using Ctrl-Shift-N,
> go back to the first window, and press Ctrl-D. The terminal's master FD gets
> events even after being closed, causing terminal_destroy to be called twice
> on the same object.
> 
> To fix this, I'm adding a function to stop watching an FD.

Thanks, that fixes the problem, committed.

Kristian

> ---
>  clients/terminal.c |    6 ++++--
>  clients/window.c   |    6 ++++++
>  clients/window.h   |    3 +++
>  3 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/clients/terminal.c b/clients/terminal.c
> index 1887829..25acc81 100644
> --- a/clients/terminal.c
> +++ b/clients/terminal.c
> @@ -2578,13 +2578,15 @@ terminal_create(struct display *display)
>  static void
>  terminal_destroy(struct terminal *terminal)
>  {
> +	display_unwatch_fd(terminal->display, terminal->master);
>  	window_destroy(terminal->window);
>  	close(terminal->master);
>  	wl_list_remove(&terminal->link);
> -	free(terminal);
>  
>  	if (wl_list_empty(&terminal_list))
> -		exit(0);
> +		display_exit(terminal->display);
> +
> +	free(terminal);
>  }
>  
>  static void
> diff --git a/clients/window.c b/clients/window.c
> index 3469fe6..b625516 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -4347,6 +4347,12 @@ display_watch_fd(struct display *display,
>  }
>  
>  void
> +display_unwatch_fd(struct display *display, int fd)
> +{
> +	epoll_ctl(display->epoll_fd, EPOLL_CTL_DEL, fd, NULL);
> +}
> +
> +void
>  display_run(struct display *display)
>  {
>  	struct task *task;
> diff --git a/clients/window.h b/clients/window.h
> index 9b820a0..804eef5 100644
> --- a/clients/window.h
> +++ b/clients/window.h
> @@ -147,6 +147,9 @@ display_watch_fd(struct display *display,
>  		 int fd, uint32_t events, struct task *task);
>  
>  void
> +display_unwatch_fd(struct display *display, int fd);
> +
> +void
>  display_run(struct display *d);
>  
>  void
> -- 
> 1.7.10.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list