ethanlcz commented on code in PR #6949: URL: https://github.com/apache/incubator-nuttx/pull/6949#discussion_r957939333
########## net/usrsock/usrsock_dev.c: ########## @@ -1129,91 +554,61 @@ static int usrsockdev_poll(FAR struct file *filep, FAR struct pollfd *fds, ****************************************************************************/ /**************************************************************************** - * Name: usrsockdev_do_request + * Name: usrsock_request ****************************************************************************/ -int usrsockdev_do_request(FAR struct usrsock_conn_s *conn, - FAR struct iovec *iov, unsigned int iovcnt) +int usrsock_request(FAR struct iovec *iov, unsigned int iovcnt) { FAR struct usrsockdev_s *dev = &g_usrsockdev; - FAR struct usrsock_request_common_s *req_head = iov[0].iov_base; - - if (!usrsockdev_is_opened(dev)) - { - ninfo("usockid=%d; daemon has closed /dev/usrsock.\n", conn->usockid); - - return -ENETDOWN; - } + int ret; - /* Get exchange id. */ + /* Set outstanding request for daemon to handle. */ - if (++dev->newxid == 0) + ret = usrsockdev_semtake(&dev->devsem); + if (ret < 0) { - ++dev->newxid; + return ret; } - req_head->xid = dev->newxid; - - /* Prepare connection for response. */ - - conn->resp.xid = req_head->xid; - conn->resp.result = -EACCES; - - ++dev->req.nbusy; /* net_lock held. */ - - /* Set outstanding request for daemon to handle. */ - - net_lockedwait_uninterruptible(&dev->req.sem); + /* device not opened */ Review Comment: done ########## net/usrsock/usrsock_dev.c: ########## @@ -1129,91 +554,61 @@ static int usrsockdev_poll(FAR struct file *filep, FAR struct pollfd *fds, ****************************************************************************/ /**************************************************************************** - * Name: usrsockdev_do_request + * Name: usrsock_request ****************************************************************************/ -int usrsockdev_do_request(FAR struct usrsock_conn_s *conn, - FAR struct iovec *iov, unsigned int iovcnt) +int usrsock_request(FAR struct iovec *iov, unsigned int iovcnt) { FAR struct usrsockdev_s *dev = &g_usrsockdev; - FAR struct usrsock_request_common_s *req_head = iov[0].iov_base; - - if (!usrsockdev_is_opened(dev)) - { - ninfo("usockid=%d; daemon has closed /dev/usrsock.\n", conn->usockid); - - return -ENETDOWN; - } + int ret; - /* Get exchange id. */ + /* Set outstanding request for daemon to handle. */ - if (++dev->newxid == 0) + ret = usrsockdev_semtake(&dev->devsem); + if (ret < 0) { - ++dev->newxid; + return ret; } - req_head->xid = dev->newxid; - - /* Prepare connection for response. */ - - conn->resp.xid = req_head->xid; - conn->resp.result = -EACCES; - - ++dev->req.nbusy; /* net_lock held. */ - - /* Set outstanding request for daemon to handle. */ - - net_lockedwait_uninterruptible(&dev->req.sem); + /* device not opened */ if (usrsockdev_is_opened(dev)) { DEBUGASSERT(dev->req.iov == NULL); - dev->req.ackxid = req_head->xid; dev->req.iov = iov; dev->req.pos = 0; dev->req.iovcnt = iovcnt; /* Notify daemon of new request. */ usrsockdev_pollnotify(dev, POLLIN); - - /* Wait ack for request. */ - - net_lockedwait_uninterruptible(&dev->req.acksem); + ret = OK; Review Comment: done -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org