mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	don't handle EINTR and EAGAIN as the same
EAGAIN means a non-blocking operation would block and we should not try again right away but leave the loop and wait instead. See #358
This commit is contained in:
		
							parent
							
								
									e094640c7b
								
							
						
					
					
						commit
						c43026d93e
					
				
					 8 changed files with 10 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1080,9 +1080,9 @@ static inline uint32_t cycle_run(struct client *c)
 | 
			
		|||
	/* this is blocking if nothing ready */
 | 
			
		||||
	while (true) {
 | 
			
		||||
		if (SPA_UNLIKELY(read(fd, &cmd, sizeof(cmd)) != sizeof(cmd))) {
 | 
			
		||||
			if (errno == EAGAIN || errno == EINTR)
 | 
			
		||||
			if (errno == EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
			if (errno == EWOULDBLOCK)
 | 
			
		||||
			if (errno == EWOULDBLOCK || errno == EAGAIN)
 | 
			
		||||
				return 0;
 | 
			
		||||
			pw_log_warn(NAME" %p: read failed %m", c);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1661,7 +1661,7 @@ static void io_event_cb(pa_mainloop_api*ea, pa_io_event* e, int fd, pa_io_event_
 | 
			
		|||
		pw_loop_enter(c->loop);
 | 
			
		||||
		do {
 | 
			
		||||
			res = pw_loop_iterate(c->loop, 0);
 | 
			
		||||
		 } while (res == -EINTR || res == -EAGAIN);
 | 
			
		||||
		} while (res == -EINTR);
 | 
			
		||||
		pw_loop_leave(c->loop);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ static gboolean source_dispatch (GSource *source, GSourceFunc callback, gpointer
 | 
			
		|||
	pw_loop_enter (s->loop);
 | 
			
		||||
	do {
 | 
			
		||||
		result = pw_loop_iterate (s->loop, 0);
 | 
			
		||||
	} while (result == -EINTR || result == -EAGAIN);
 | 
			
		||||
	} while (result == -EINTR);
 | 
			
		||||
	pw_loop_leave (s->loop);
 | 
			
		||||
 | 
			
		||||
	if (result < 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -354,7 +354,7 @@ int pa_mainloop_poll(pa_mainloop *m)
 | 
			
		|||
		pw_loop_enter(m->loop);
 | 
			
		||||
		do {
 | 
			
		||||
			res = pw_loop_iterate(m->loop, timeout);
 | 
			
		||||
		} while (res == -EINTR || res == -EAGAIN);
 | 
			
		||||
		} while (res == -EINTR);
 | 
			
		||||
		pw_loop_leave(m->loop);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1345,7 +1345,7 @@ int sm_media_session_roundtrip(struct sm_media_session *sess)
 | 
			
		|||
	pw_loop_enter(loop);
 | 
			
		||||
	while (!done) {
 | 
			
		||||
		if ((res = pw_loop_iterate(loop, -1)) < 0) {
 | 
			
		||||
			if (res == -EINTR || res == -EAGAIN)
 | 
			
		||||
			if (res == -EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
			pw_log_warn(NAME" %p: iterate error %d (%s)",
 | 
			
		||||
				loop, res, spa_strerror(res));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ int pw_data_loop_wait(struct pw_data_loop *this, int timeout)
 | 
			
		|||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		if ((res = pw_loop_iterate(this->loop, timeout)) < 0) {
 | 
			
		||||
			if (res == -EINTR || res == -EAGAIN)
 | 
			
		||||
			if (res == -EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ static void *do_loop(void *user_data)
 | 
			
		|||
 | 
			
		||||
	while (this->running) {
 | 
			
		||||
		if ((res = pw_loop_iterate(this->loop, -1)) < 0) {
 | 
			
		||||
			if (res == -EINTR || res == -EAGAIN)
 | 
			
		||||
			if (res == -EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
			pw_log_error(NAME" %p: iterate error %d (%s)",
 | 
			
		||||
					this, res, spa_strerror(res));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -154,7 +154,7 @@ int pw_main_loop_run(struct pw_main_loop *loop)
 | 
			
		|||
	pw_loop_enter(loop->loop);
 | 
			
		||||
	while (loop->running) {
 | 
			
		||||
		if ((res = pw_loop_iterate(loop->loop, -1)) < 0) {
 | 
			
		||||
			if (res == -EINTR || res == -EAGAIN)
 | 
			
		||||
			if (res == -EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
			pw_log_warn(NAME" %p: iterate error %d (%s)",
 | 
			
		||||
					loop, res, spa_strerror(res));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -239,7 +239,7 @@ static void *do_loop(void *user_data)
 | 
			
		|||
 | 
			
		||||
	while (this->running) {
 | 
			
		||||
		if ((res = pw_loop_iterate(this->loop, -1)) < 0) {
 | 
			
		||||
			if (res == -EINTR || res == -EAGAIN)
 | 
			
		||||
			if (res == -EINTR)
 | 
			
		||||
				continue;
 | 
			
		||||
			pw_log_warn(NAME" %p: iterate error %d (%s)",
 | 
			
		||||
					this, res, spa_strerror(res));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue