This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 272e62018a sim/posix/sim_hostusrsock: process host network syscall 
with critical section
272e62018a is described below

commit 272e62018a190c605efc131fdd557598a031642c
Author: zhanghongyu <[email protected]>
AuthorDate: Fri May 12 18:10:45 2023 +0800

    sim/posix/sim_hostusrsock: process host network syscall with critical 
section
    
    if config_walltime_signal is enabled, NuttX_sim will receive a lot of
    signals, the socket api will break and errno will be EINTR, masking irq
    before calling the host socket api will avoid this problem.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 arch/sim/src/sim/sim_usrsock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sim/src/sim/sim_usrsock.c b/arch/sim/src/sim/sim_usrsock.c
index 3d5789674b..08c93cc53d 100644
--- a/arch/sim/src/sim/sim_usrsock.c
+++ b/arch/sim/src/sim/sim_usrsock.c
@@ -28,6 +28,7 @@
 #include <syslog.h>
 #include <string.h>
 
+#include <nuttx/arch.h>
 #include <nuttx/net/usrsock.h>
 
 #include "sim_hostusrsock.h"
@@ -408,6 +409,7 @@ void usrsock_register(void)
 int usrsock_request(struct iovec *iov, unsigned int iovcnt)
 {
   struct usrsock_request_common_s *common;
+  uint64_t flags;
   int ret;
 
   /* Copy request to buffer */
@@ -424,8 +426,10 @@ int usrsock_request(struct iovec *iov, unsigned int iovcnt)
   if (common->reqid >= 0 &&
       common->reqid < USRSOCK_REQUEST__MAX)
     {
+      flags = up_irq_save();
       ret = g_usrsock_handler[common->reqid](&g_usrsock,
                                               g_usrsock.in, ret);
+      up_irq_restore(flags);
       if (ret < 0)
         {
           syslog(LOG_ERR, "Usrsock request %d failed: %d\n",

Reply via email to