casaroli commented on code in PR #21910:
URL: https://github.com/apache/nuttx/pull/21910#discussion_r4612699062


##########
audio/audio.c:
##########
@@ -89,6 +89,7 @@ struct audio_upperhalf_s
 {
   struct audio_info_s          info;     /* Record the last playing audio 
format */
   mutex_t                      lock;     /* Supports mutual exclusion */
+  mutex_t                      mqlock;   /* Keeps the opens for a thread that 
sends */

Review Comment:
   `audio_ioctl()` holds `upper->lock` while it calls the lower half, and a 
lower half can call back in the same thread: `null_stop()` calls 
`AUDIO_CALLBACK_COMPLETE` (audio_null.c:666). `audio_sendmsg()` would then take 
`upper->lock` a second time and deadlock. `mqlock` only keeps the list of opens 
and their queues.
   



##########
audio/audio.c:
##########
@@ -1573,11 +1582,22 @@ static inline void audio_sendmsg(FAR struct 
audio_upperhalf_s *upper,
   FAR struct audio_openpriv_s *priv;
   pollevent_t eventset;
   irqstate_t flags;
+  bool intr = up_interrupt_context();
+
+  /* In a thread, file_mq_send() can wait for room in a full queue and can

Review Comment:
   With O_NONBLOCK a full queue drops the message: the application loses an 
`AUDIO_MSG_DEQUEUE` and does not get that buffer back. Also `file_mq_send()` 
still calls `kmm_malloc()` in a thread when the free list is empty 
(sched/mqueue/mq_send.c:187).
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to