xiaoxiang781216 commented on code in PR #17734:
URL: https://github.com/apache/nuttx/pull/17734#discussion_r2653116689


##########
include/nuttx/net/usrsock.h:
##########
@@ -267,6 +269,124 @@ begin_packed_struct struct usrsock_message_socket_event_s
   int16_t usockid;
 } end_packed_struct;
 
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* Global protection lock for usrsock socket */
+
+extern rmutex_t g_usrsock_lock;
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: usrsock_lock
+ *
+ * Description:
+ *   Take the global usrsock socket lock
+ *
+ ****************************************************************************/
+
+static inline_function void usrsock_lock(void)
+{
+  nxrmutex_lock(&g_usrsock_lock);
+}
+
+/****************************************************************************
+ * Name: usrsock_unlock
+ *
+ * Description:
+ *   Release the global usrsock socket lock
+ *
+ ****************************************************************************/
+
+static inline_function void usrsock_unlock(void)
+{
+  nxrmutex_unlock(&g_usrsock_lock);
+}
+
+/****************************************************************************
+ * Name: usrsock_sem_timedwait
+ *
+ * Description:
+ *   Wait for sem while temporarily releasing the usrsock lock.
+ *
+ ****************************************************************************/
+
+static inline_function int
+usrsock_sem_timedwait(FAR sem_t *sem, bool interruptible,
+                      unsigned int timeout)
+{
+#ifdef CONFIG_NET
+  return net_sem_timedwait2(sem, interruptible, timeout, &g_usrsock_lock,
+                            NULL);
+#else
+  return 0;

Review Comment:
   it's wrong to no-op when CONFIG_NET isn't enabled.



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