mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Close timer file descriptors in event loop on remove and failure.
When the timer is removed the corresponding fd is closed. This should automatically remove it from the epoll set.
This commit is contained in:
		
							parent
							
								
									61ce8749a7
								
							
						
					
					
						commit
						1081bca2a8
					
				
					 1 changed files with 3 additions and 5 deletions
				
			
		| 
						 | 
					@ -171,13 +171,10 @@ wl_event_source_timer_remove(struct wl_event_source *source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_event_source_timer *timer_source =
 | 
						struct wl_event_source_timer *timer_source =
 | 
				
			||||||
		(struct wl_event_source_timer *) source;
 | 
							(struct wl_event_source_timer *) source;
 | 
				
			||||||
	struct wl_event_loop *loop = source->loop;
 | 
					 | 
				
			||||||
	int fd;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fd = timer_source->fd;
 | 
						close(timer_source->fd);
 | 
				
			||||||
	free(source);
 | 
						free(source);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
	return epoll_ctl(loop->epoll_fd, EPOLL_CTL_DEL, fd, NULL);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_event_source_interface timer_source_interface = {
 | 
					struct wl_event_source_interface timer_source_interface = {
 | 
				
			||||||
| 
						 | 
					@ -215,6 +212,7 @@ wl_event_loop_add_timer(struct wl_event_loop *loop,
 | 
				
			||||||
	ep.data.ptr = source;
 | 
						ep.data.ptr = source;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) {
 | 
						if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) {
 | 
				
			||||||
 | 
							close(source->fd);
 | 
				
			||||||
		free(source);
 | 
							free(source);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue