Skip to content

Commit

Permalink
Add try/catch block around message queue recive method in the engine
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Sep 8, 2024
1 parent 937e306 commit c70ac2e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/vizdoom/src/viz_message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ void VIZ_MQSend(uint8_t code, const char * command){
}

void VIZ_MQReceive(void *msg) {
size_t size;
unsigned int priority;
if(vizMQDoom) {
size_t size;
unsigned int priority;

if(vizMQDoom) vizMQDoom->receive(msg, sizeof(VIZMessage), size, priority);
try{
vizMQDoom->receive(msg, sizeof(VIZMessage), size, priority);
}
catch(...){ // bip::interprocess_exception
VIZ_Error(VIZ_FUNC, "Failed to receive message.");
}

VIZ_DebugMsg(4, VIZ_FUNC, "Received msg: %d.", static_cast<VIZMessage *>(msg)->code);
VIZ_DebugMsg(4, VIZ_FUNC, "Received msg: %d.", static_cast<VIZMessage *>(msg)->code);
}
}

bool VIZ_MQTryReceive(void *msg){
Expand Down

0 comments on commit c70ac2e

Please sign in to comment.