forked from xuos/xiuos
消息队列接收与紧急发送代码修改 #1
Loading…
Reference in New Issue
No description provided.
Delete Branch "msg_que_modifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题1描述
msgqueue.c的_MsgQueueRecv函数中,条件判断mq->index==0 && timeout == 0为真时,会返回接收超时错误,但此时消息队列中可能是存在消息的。
问题1复现步骤
根本原因
借助mq->index==0对循环队列判空
修复方案
将问题描述中的条件判断mq->index==0 && timeout == 0改为timeout == 0 && mq->num_msgs <= 0
问题2描述
msgqueue.c的_MsgQueueUrgentSend函数中,先对mq->index(消息接收位置)自减,再基于其新值,利用msg = mq->msg_buf + ( ( mq->index + mq->num_msgs ) % mq->max_msgs ) * mq->each_len计算要将消息发送到的目标位置时出错。新消息会被发送至队尾而不是队头位置,且新消息可能覆盖已有消息。
问题2复现步骤
根本原因
计算消息发送到的目标位置的表达式mq->msg_buf + ( ( mq->index + mq->num_msgs ) % mq->max_msgs ) * mq->each_len有误
修复方案
将计算目标位置的表达式改为mq->msg_buf + (mq->index % mq->max_msgs) * mq->each_len