|
|
@@ -96,14 +96,15 @@ bh_queue_destroy(bh_queue *queue)
|
|
|
bool
|
|
|
bh_post_msg2(bh_queue *queue, bh_queue_node *msg)
|
|
|
{
|
|
|
+ bh_queue_mutex_lock(&queue->queue_lock);
|
|
|
+
|
|
|
if (queue->cnt >= queue->max) {
|
|
|
queue->drops++;
|
|
|
bh_free_msg(msg);
|
|
|
+ bh_queue_mutex_unlock(&queue->queue_lock);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- bh_queue_mutex_lock(&queue->queue_lock);
|
|
|
-
|
|
|
if (queue->cnt == 0) {
|
|
|
bh_assert(queue->head == NULL);
|
|
|
bh_assert(queue->tail == NULL);
|
|
|
@@ -131,7 +132,9 @@ bh_post_msg(bh_queue *queue, unsigned short tag, void *body, unsigned int len)
|
|
|
{
|
|
|
bh_queue_node *msg = bh_new_msg(tag, body, len, NULL);
|
|
|
if (msg == NULL) {
|
|
|
+ bh_queue_mutex_lock(&queue->queue_lock);
|
|
|
queue->drops++;
|
|
|
+ bh_queue_mutex_unlock(&queue->queue_lock);
|
|
|
if (len != 0 && body)
|
|
|
BH_FREE(body);
|
|
|
return false;
|