-
The following interleaving can cause problems: The interrupt for SIGINT could set sig_request.cancel right after the consumer thread checks it ("buf->cancel_flag || sig_request.cancel"), but before the consumer thread enters the mutex in order to wait for more data ("COND_WAIT"). If the producer thread reacts to the new situation immediately by exiting (which it can do because the consumer thread hasn't entered the mutex yet), the consumer thread initiates a COND_WAIT that might never be fulfilled because the producer thread is gone. The producer's intention to kill the consumer using buffer_thread_kill doesn't work because it was executed after the consumer's check for buf->cancel_flag and before the consumer's COND_WAIT. Fix the problem by putting the cancelation flag checks in the same mutex lock zone as the "COND_WAIT".
6d670e7c