mirror of
https://github.com/apache/nuttx.git
synced 2026-08-11 07:25:13 +00:00
net/usrsock/: Correct of semphore usage issues.
This commit is contained in:
parent
4c61565bbc
commit
67193ff5c4
2 changed files with 8 additions and 3 deletions
|
|
@ -253,6 +253,8 @@ int usrsock_setup_request_callback(FAR struct usrsock_conn_s *conn,
|
|||
int ret = -EBUSY;
|
||||
|
||||
(void)nxsem_init(&pstate->recvsem, 0, 0);
|
||||
nxsem_setprotocol(&pstate->recvsem, SEM_PRIO_NONE);
|
||||
|
||||
pstate->conn = conn;
|
||||
pstate->result = -EAGAIN;
|
||||
pstate->completed = false;
|
||||
|
|
@ -299,6 +301,7 @@ void usrsock_teardown_request_callback(FAR struct usrsock_reqstate_s *pstate)
|
|||
/* Make sure that no further events are processed */
|
||||
|
||||
devif_conn_callback_free(NULL, pstate->cb, &conn->list);
|
||||
nxsem_destroy(&pstate->recvsem);
|
||||
|
||||
pstate->cb = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,8 +274,8 @@ static uint8_t usrsockdev_get_xid(FAR struct usrsock_conn_s *conn)
|
|||
{
|
||||
int conn_idx;
|
||||
|
||||
#if CONFIG_NET_USRSOCK_CONNS > 255
|
||||
# error "CONFIG_NET_USRSOCK_CONNS too large (over 255)"
|
||||
#if CONFIG_NET_USRSOCK_CONNS > 254
|
||||
# error "CONFIG_NET_USRSOCK_CONNS too large (over 254)"
|
||||
#endif
|
||||
|
||||
/* Each connection can one only one request/response pending. So map
|
||||
|
|
@ -1240,6 +1240,7 @@ int usrsockdev_do_request(FAR struct usrsock_conn_s *conn,
|
|||
else
|
||||
{
|
||||
ninfo("usockid=%d; daemon abruptly closed /usr/usrsock.\n", conn->usockid);
|
||||
ret = -ESHUTDOWN;
|
||||
}
|
||||
|
||||
/* Free request line for next command. */
|
||||
|
|
@ -1248,7 +1249,7 @@ int usrsockdev_do_request(FAR struct usrsock_conn_s *conn,
|
|||
|
||||
--dev->req.nbusy; /* net_lock held. */
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -1268,6 +1269,7 @@ void usrsockdev_register(void)
|
|||
nxsem_init(&g_usrsockdev.devsem, 0, 1);
|
||||
nxsem_init(&g_usrsockdev.req.sem, 0, 1);
|
||||
nxsem_init(&g_usrsockdev.req.acksem, 0, 0);
|
||||
nxsem_setprotocol(&g_usrsockdev.req.acksem, SEM_PRIO_NONE);
|
||||
|
||||
(void)register_driver("/dev/usrsock", &g_usrsockdevops, 0666, &g_usrsockdev);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue