mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	fdsem: be more verbose when reading from eventfd fails.
Apperently reading from an eventfd can fail, which results in an assert to be hit. I am not sure about the reason for the failure, but in attempt to track down the issue the next time is hit this prints a more useful log message. https://bugzilla.redhat.com/attachment.cgi?id=386380
This commit is contained in:
		
							parent
							
								
									96592c2115
								
							
						
					
					
						commit
						5e2af2d3f3
					
				
					 1 changed files with 35 additions and 6 deletions
				
			
		| 
						 | 
					@ -35,6 +35,7 @@
 | 
				
			||||||
#include <pulsecore/thread.h>
 | 
					#include <pulsecore/thread.h>
 | 
				
			||||||
#include <pulsecore/macro.h>
 | 
					#include <pulsecore/macro.h>
 | 
				
			||||||
#include <pulsecore/core-util.h>
 | 
					#include <pulsecore/core-util.h>
 | 
				
			||||||
 | 
					#include <pulsecore/core-error.h>
 | 
				
			||||||
#include <pulse/xmalloc.h>
 | 
					#include <pulse/xmalloc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef HAVE_PIPE
 | 
					#ifndef HAVE_PIPE
 | 
				
			||||||
| 
						 | 
					@ -159,7 +160,12 @@ static void flush(pa_fdsem *f) {
 | 
				
			||||||
            uint64_t u;
 | 
					            uint64_t u;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
					            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
				
			||||||
                pa_assert(r < 0 && errno == EINTR);
 | 
					
 | 
				
			||||||
 | 
					                if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                    pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                    pa_assert_not_reached();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            r = (ssize_t) u;
 | 
					            r = (ssize_t) u;
 | 
				
			||||||
| 
						 | 
					@ -167,7 +173,12 @@ static void flush(pa_fdsem *f) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
 | 
					        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
 | 
				
			||||||
            pa_assert(r < 0 && errno == EINTR);
 | 
					
 | 
				
			||||||
 | 
					            if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                pa_assert_not_reached();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,14 +203,22 @@ void pa_fdsem_post(pa_fdsem *f) {
 | 
				
			||||||
                    uint64_t u = 1;
 | 
					                    uint64_t u = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((r = write(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
					                    if ((r = write(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
				
			||||||
                        pa_assert(r < 0 && errno == EINTR);
 | 
					                        if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                            pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                            pa_assert_not_reached();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                } else
 | 
					                } else
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ((r = write(f->fds[1], &x, 1)) != 1) {
 | 
					                if ((r = write(f->fds[1], &x, 1)) != 1) {
 | 
				
			||||||
                    pa_assert(r < 0 && errno == EINTR);
 | 
					                    if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                        pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                        pa_assert_not_reached();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -228,7 +247,12 @@ void pa_fdsem_wait(pa_fdsem *f) {
 | 
				
			||||||
            uint64_t u;
 | 
					            uint64_t u;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
					            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
 | 
				
			||||||
                pa_assert(r < 0 && errno == EINTR);
 | 
					
 | 
				
			||||||
 | 
					                if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                    pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                    pa_assert_not_reached();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -237,7 +261,12 @@ void pa_fdsem_wait(pa_fdsem *f) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
 | 
					        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
 | 
				
			||||||
            pa_assert(r < 0 && errno == EINTR);
 | 
					
 | 
				
			||||||
 | 
					            if (r >= 0 || errno != EINTR) {
 | 
				
			||||||
 | 
					                pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
 | 
				
			||||||
 | 
					                pa_assert_not_reached();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue