Skip to content

Commit

Permalink
Improper ownership handling of message objects in worker thread (prob…
Browse files Browse the repository at this point in the history
…ably fixes #19)
  • Loading branch information
BatchDrake committed Aug 21, 2019
1 parent d3eaa79 commit 2af94a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions analyzer/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ suscan_worker_thread(void *data)
/* Callback returns FALSE: remove from message queue */
suscan_worker_callback_destroy(cb);
suscan_msg_destroy(msg);
msg = NULL;
} else {
/* Callback returns TRUE: queue again */
suscan_mq_write_msg(&worker->mq_in, msg);
Expand All @@ -114,9 +113,14 @@ suscan_worker_thread(void *data)
default:
SU_WARNING("Unexpected worker message type #%d\n", msg->type);
suscan_msg_destroy(msg); /* Destroy message anyways */
msg = NULL;
}

/*
* We reached this point, one way or another, we don't hold the
* ownership of the message anymore.
*/
msg = NULL;

/* Next reads: until queue is empty */
} while (
!worker->halt_req
Expand Down

0 comments on commit 2af94a1

Please sign in to comment.