mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	protocol-native: attempt to remove socket
After we grab the lockfile we should remove the socket when it exists so that we can bind again. This should solve startup problems after a crash, which left the socket around and caused bind failures.
This commit is contained in:
		
							parent
							
								
									1bbb144b59
								
							
						
					
					
						commit
						ca34a75173
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -434,10 +434,22 @@ static int add_socket(struct pw_protocol *protocol, struct server *s)
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
	if (fd < 0) {
 | 
			
		||||
		struct stat socket_stat;
 | 
			
		||||
 | 
			
		||||
		if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
 | 
			
		||||
			res = -errno;
 | 
			
		||||
			goto error;
 | 
			
		||||
		}
 | 
			
		||||
		if (stat(s->addr.sun_path, &socket_stat) < 0) {
 | 
			
		||||
			if (errno != ENOENT) {
 | 
			
		||||
				res = -errno;
 | 
			
		||||
				pw_log_error("server %p: stat %s failed with error: %m",
 | 
			
		||||
						s, s->addr.sun_path);
 | 
			
		||||
				goto error_close;
 | 
			
		||||
			}
 | 
			
		||||
		} else if (socket_stat.st_mode & S_IWUSR || socket_stat.st_mode & S_IWGRP) {
 | 
			
		||||
			unlink(s->addr.sun_path);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		size = offsetof(struct sockaddr_un, sun_path) + strlen(s->addr.sun_path);
 | 
			
		||||
		if (bind(fd, (struct sockaddr *) &s->addr, size) < 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue