Merge pull request #8808 from RandomShaper/mq-flush-reentrant-2.1
Make MessageQueue::flush() reentrant (2.1)
This commit is contained in:
commit
23fb7d29c2
|
@ -316,12 +316,19 @@ void MessageQueue::flush() {
|
||||||
|
|
||||||
while (read_pos < buffer_end) {
|
while (read_pos < buffer_end) {
|
||||||
|
|
||||||
_THREAD_SAFE_UNLOCK_
|
|
||||||
|
|
||||||
//lock on each interation, so a call can re-add itself to the message queue
|
//lock on each interation, so a call can re-add itself to the message queue
|
||||||
|
|
||||||
Message *message = (Message *)&buffer[read_pos];
|
Message *message = (Message *)&buffer[read_pos];
|
||||||
|
|
||||||
|
uint32_t advance = sizeof(Message);
|
||||||
|
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION)
|
||||||
|
advance += sizeof(Variant) * message->args;
|
||||||
|
|
||||||
|
//pre-advance so this function is reentrant
|
||||||
|
read_pos += advance;
|
||||||
|
|
||||||
|
_THREAD_SAFE_UNLOCK_
|
||||||
|
|
||||||
Object *target = ObjectDB::get_instance(message->instance_ID);
|
Object *target = ObjectDB::get_instance(message->instance_ID);
|
||||||
|
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
|
@ -357,13 +364,9 @@ void MessageQueue::flush() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t advance = sizeof(Message);
|
|
||||||
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION)
|
|
||||||
advance += sizeof(Variant) * message->args;
|
|
||||||
message->~Message();
|
message->~Message();
|
||||||
|
|
||||||
_THREAD_SAFE_LOCK_
|
_THREAD_SAFE_LOCK_
|
||||||
read_pos += advance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_end = 0; // reset buffer
|
buffer_end = 0; // reset buffer
|
||||||
|
|
Loading…
Reference in New Issue