mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	Mark shared variables as volatile
'n_waiting' and 'n_waiting_for_accept' may be accessed from mulitple threads, and thus need to be marked as volatile to suppres certain compiler optimisations. All uses are protected by a mutex, so we don't need to worry about cache issues (added documentation for this as well). This addresses bug #738.
This commit is contained in:
		
							parent
							
								
									48e0f6808b
								
							
						
					
					
						commit
						366e6d7e90
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -51,7 +51,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pa_threaded_mainloop {
 | 
					struct pa_threaded_mainloop {
 | 
				
			||||||
    pa_mainloop *real_mainloop;
 | 
					    pa_mainloop *real_mainloop;
 | 
				
			||||||
    int n_waiting, n_waiting_for_accept;
 | 
					    volatile int n_waiting, n_waiting_for_accept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_thread* thread;
 | 
					    pa_thread* thread;
 | 
				
			||||||
    pa_mutex* mutex;
 | 
					    pa_mutex* mutex;
 | 
				
			||||||
| 
						 | 
					@ -185,6 +185,7 @@ void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) {
 | 
				
			||||||
    pa_mutex_unlock(m->mutex);
 | 
					    pa_mutex_unlock(m->mutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called with the lock taken */
 | 
				
			||||||
void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
 | 
					void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -198,6 +199,7 @@ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called with the lock taken */
 | 
				
			||||||
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
 | 
					void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -212,6 +214,7 @@ void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
 | 
				
			||||||
    m->n_waiting --;
 | 
					    m->n_waiting --;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Called with the lock taken */
 | 
				
			||||||
void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
 | 
					void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
 | 
				
			||||||
    pa_assert(m);
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue