mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	udev: process all inotify events queued up, not just the first one in the queue
This commit is contained in:
		
							parent
							
								
									1a05d67f07
								
							
						
					
					
						commit
						560da5b0a1
					
				
					 1 changed files with 37 additions and 15 deletions
				
			
		| 
						 | 
					@ -325,6 +325,7 @@ static void inotify_cb(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (;;) {
 | 
					    for (;;) {
 | 
				
			||||||
        ssize_t r;
 | 
					        ssize_t r;
 | 
				
			||||||
 | 
					        struct inotify_event *event;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_zero(buf);
 | 
					        pa_zero(buf);
 | 
				
			||||||
        if ((r = pa_read(fd, &buf, sizeof(buf), &type)) <= 0) {
 | 
					        if ((r = pa_read(fd, &buf, sizeof(buf), &type)) <= 0) {
 | 
				
			||||||
| 
						 | 
					@ -336,23 +337,44 @@ static void inotify_cb(
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        event = &buf.e;
 | 
				
			||||||
 | 
					        while (r > 0) {
 | 
				
			||||||
 | 
					            size_t len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ((size_t) r < sizeof(struct inotify_event)) {
 | 
				
			||||||
 | 
					                pa_log("read() too short.");
 | 
				
			||||||
 | 
					                goto fail;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            len = sizeof(struct inotify_event) + event->len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ((size_t) r < len) {
 | 
				
			||||||
 | 
					                pa_log("Payload missing.");
 | 
				
			||||||
 | 
					                goto fail;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* From udev we get the guarantee that the control
 | 
					            /* From udev we get the guarantee that the control
 | 
				
			||||||
         * device's ACL is changes last. To avoid races when ACLs
 | 
					             * device's ACL is changed last. To avoid races when ACLs
 | 
				
			||||||
             * are changed we hence watch only the control device */
 | 
					             * are changed we hence watch only the control device */
 | 
				
			||||||
        if (((buf.e.mask & IN_ATTRIB) && pa_startswith(buf.e.name, "controlC")))
 | 
					            if (((event->mask & IN_ATTRIB) && pa_startswith(event->name, "controlC")))
 | 
				
			||||||
                PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
					                PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
				
			||||||
                if (control_node_belongs_to_device(d, buf.e.name))
 | 
					                    if (control_node_belongs_to_device(d, event->name))
 | 
				
			||||||
                        d->need_verify = TRUE;
 | 
					                        d->need_verify = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /* ALSA doesn't really give us any guarantee on the closing
 | 
					            /* ALSA doesn't really give us any guarantee on the closing
 | 
				
			||||||
             * order, so let's simply hope */
 | 
					             * order, so let's simply hope */
 | 
				
			||||||
        if (((buf.e.mask & IN_CLOSE_WRITE) && pa_startswith(buf.e.name, "pcmC")))
 | 
					            if (((event->mask & IN_CLOSE_WRITE) && pa_startswith(event->name, "pcmC")))
 | 
				
			||||||
                PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
					                PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
				
			||||||
                if (pcm_node_belongs_to_device(d, buf.e.name))
 | 
					                    if (pcm_node_belongs_to_device(d, event->name))
 | 
				
			||||||
                        d->need_verify = TRUE;
 | 
					                        d->need_verify = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((buf.e.mask & (IN_DELETE_SELF|IN_MOVE_SELF)))
 | 
					            /* /dev/snd/ might have been removed */
 | 
				
			||||||
 | 
					            if ((event->mask & (IN_DELETE_SELF|IN_MOVE_SELF)))
 | 
				
			||||||
                deleted = TRUE;
 | 
					                deleted = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            event = (struct inotify_event*) ((uint8_t*) event + len);
 | 
				
			||||||
 | 
					            r -= len;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
					    PA_HASHMAP_FOREACH(d, u->devices, state)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue