BMediaNode: Handle port read syscall interrupts by retrying.

The syscall might be interrupted, especially in signal heavy
applications. In that case we need to retry the read until the timeout
runs out. since the timeout is already absolute we don't need to adjust
anything.
This commit is contained in:
Michael Lotz 2013-05-05 18:00:04 +02:00
parent ab2e15ab8c
commit ec4d0e426d

View File

@ -364,13 +364,23 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
char data[B_MEDIA_MESSAGE_SIZE]; // about 16 KByte stack used
int32 message;
ssize_t size = read_port_etc(ControlPort(), &message, data, sizeof(data),
B_ABSOLUTE_TIMEOUT, waitUntil);
if (size < 0) {
ssize_t size;
while (true) {
size = read_port_etc(ControlPort(), &message, data,
sizeof(data), B_ABSOLUTE_TIMEOUT, waitUntil);
if (size >= 0)
break;
status_t error = (status_t)size;
if (error != B_TIMED_OUT && error != B_BAD_PORT_ID)
if (error == B_INTERRUPTED)
continue;
if (error != B_TIMED_OUT && error != B_BAD_PORT_ID) {
ERROR("BMediaNode::WaitForMessage: read_port_etc error: %s\n",
strerror(error));
}
return error;
}