@@ -87,6 +87,11 @@ WaitForConsumption(IPCMessage* aMsg, IPCMessageReply* aReply)
87
87
int
88
88
IPCMessageWaitForReply (IPCMessage * aMsg )
89
89
{
90
+ if (aMsg -> mStatus & IPC_MESSAGE_FLAG_NOWAIT ) {
91
+ /* The consumer won't reply to us, so we're
92
+ * returning an error here. */
93
+ return -1 ;
94
+ }
90
95
IPCMessageReply reply ;
91
96
int res = WaitForConsumption (aMsg , & reply );
92
97
if (res < 0 ) {
@@ -102,6 +107,13 @@ IPCMessageWaitForReply(IPCMessage* aMsg)
102
107
int
103
108
IPCMessageWaitForConsumption (IPCMessage * aMsg )
104
109
{
110
+ if (aMsg -> mStatus & IPC_MESSAGE_FLAG_NOWAIT ) {
111
+ /* The consumer won't send a reply. We simply reset
112
+ * the message state and succeed silently. */
113
+ aMsg -> mStatus &= 0x0fffffff ;
114
+ aMsg -> mStatus |= IPC_MESSAGE_STATE_CLEAR ;
115
+ return 0 ;
116
+ }
105
117
IPCMessageReply reply ;
106
118
int res = WaitForConsumption (aMsg , & reply );
107
119
if (res < 0 ) {
@@ -127,6 +139,11 @@ IPCMessageConsumeAndReply(IPCMessage* aMsg,
127
139
uint32_t aFlags , uint32_t aLength ,
128
140
void * aBuffer )
129
141
{
142
+ if (aMsg -> mStatus & IPC_MESSAGE_FLAG_NOWAIT ) {
143
+ /* We cannot reply because the producer doesn't
144
+ * wait for the consumption of the message. */
145
+ return -1 ;
146
+ }
130
147
IPCMessageReply reply = {
131
148
.mDWord0 = aDWord0 ,
132
149
.mDWord1 = aDWord1 ,
@@ -139,6 +156,9 @@ IPCMessageConsumeAndReply(IPCMessage* aMsg,
139
156
int
140
157
IPCMessageConsume (IPCMessage * aMsg )
141
158
{
159
+ if (aMsg -> mStatus & IPC_MESSAGE_FLAG_NOWAIT ) {
160
+ return 0 ; /* Silently succeed */
161
+ }
142
162
static const IPCMessageReply sReply = {
143
163
.mDWord0 = 0 ,
144
164
.mDWord1 = 0 ,
@@ -186,8 +206,15 @@ IPCMessageQueueConsume(IPCMessageQueue* aMsgQueue, IPCMessage* aMsg)
186
206
return -1 ;
187
207
}
188
208
209
+ /* Usually the consumer will send a reply after the message has
210
+ * been processed. Except if we set the NOWAIT flag. In this case
211
+ * we reset the message state to CLEAR. */
189
212
aMsg -> mStatus &= 0x0fffffff ;
190
- aMsg -> mStatus |= IPC_MESSAGE_STATE_PENDING ;
213
+ if (aMsg -> mStatus & IPC_MESSAGE_FLAG_NOWAIT ) {
214
+ aMsg -> mStatus |= IPC_MESSAGE_STATE_CLEAR ;
215
+ } else {
216
+ aMsg -> mStatus |= IPC_MESSAGE_STATE_PENDING ;
217
+ }
191
218
192
219
BaseType_t res = xQueueSend (aMsgQueue -> mWaitQueue , aMsg , 0 );
193
220
if (res != pdPASS ){
0 commit comments