Fixed deadlock that occured when quitting media applications.

I don't know why this never happened on R5. Haiku close_port() 
works as documented in BeBook, but might possibly different in R5.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16629 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen 2006-03-07 14:37:17 +00:00
parent 9638d4c877
commit 3bb81a4239
2 changed files with 7 additions and 5 deletions

View File

@ -433,18 +433,18 @@ void
BMediaEventLooper::Quit()
{
CALLED();
status_t err;
if (fRunState == B_TERMINATED)
return;
SetRunState(B_QUITTING);
write_port(ControlPort(), 0, NULL, 0); // null message to unblock the read (see BMediaNode::WaitForMessage)
close_port(ControlPort());
if (fControlThread != -1)
if (fControlThread != -1) {
status_t err;
wait_for_thread(fControlThread, &err);
fControlThread = -1;
fControlThread = -1;
}
SetRunState(B_TERMINATED);
}

View File

@ -359,6 +359,8 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
size = read_port_etc(ControlPort(), &message, data, sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil);
if (size <= 0) {
if (size == 0 && message == 0)
return B_OK; // a null message was received (to unblock the read)
if (size != B_TIMED_OUT)
ERROR("BMediaNode::WaitForMessage: read_port_etc error 0x%08lx\n",size);
return size; // returns the error code