jlaitine commented on code in PR #17263:
URL: https://github.com/apache/nuttx/pull/17263#discussion_r2479038347


##########
sched/signal/sig_dispatch.c:
##########
@@ -345,73 +345,49 @@ static FAR sigpendq_t *nxsig_add_pendingsignal(FAR struct 
tcb_s *stcb,
  *
  * Description:
  *   Dynamically allocate more pending signal and pending sigaction
- *   structures, if there are no more left. Note that this leaves the
- *   the critical section for the allocation. During that time it is
- *   it is possible that structures are freed, or another signalling thread
- *   allocates more structures. This is not an issue, any extra pending
- *   structures are freed after they get used.
- *
- * Assumptions:
- *   Called with g_sigpendingsignal and g_sigpendingaction locked by
- *   critical section.
+ *   structures, if there are no more left.
  *
  ****************************************************************************/
 
-static irqstate_t nxsig_alloc_dyn_pending(irqstate_t flags)
+static int nxsig_alloc_dyn_pending(bool alloc_signal, bool alloc_sigact)
 {
-  if (!up_interrupt_context())
-    {
-      bool alloc_signal = sq_empty(&g_sigpendingsignal);
-      bool alloc_sigact = sq_empty(&g_sigpendingaction);
-
-      /* Signals are not dispatched from the idle task */
+  int ret = OK;
+  FAR sigpendq_t *sigpend = NULL;
+  FAR sigq_t *sigq = NULL;
 
-      DEBUGASSERT(!sched_idletask());
+  /* Allocate more pending signals if there are no more */
 
-      if (alloc_signal || alloc_sigact)
+  if (alloc_signal)
+    {
+      sigpend = kmm_malloc(sizeof(sigpendq_t));
+      if (sigpend)
         {
-          FAR sigpendq_t *sigpend = NULL;
-          FAR sigq_t *sigq = NULL;
-
-          /* Leave critical section for the duration of heap operations */
-
-          leave_critical_section(flags);
-
-          /* Allocate more pending signals if there are no more */
-
-          if (alloc_signal)
-            {
-              sigpend = kmm_malloc(sizeof(sigpendq_t));
-            }
-
-          /* Allocate more pending signal actions if there are no more */
-
-          if (alloc_sigact)
-            {
-              sigq = kmm_malloc(sizeof(sigq_t));
-            }
-
-          /* Restore critical section and add the allocated structures to
-           * the free pending queues
-           */
-
-          flags = enter_critical_section();
+          sigpend->type = SIG_ALLOC_DYN;
+          sq_addfirst((sq_entry_t *)sigpend, &g_sigpendingsignal);

Review Comment:
   I just reverted to the previous solution.
   
   It is smaller change, and quite clean. Also checking the sq_empty again is 
just checking one pointer, so I think it is less work to do just that.
   



-- 
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