net/usrsock/: Correct of semphore usage issues.
This commit is contained in:
parent
4c61565bbc
commit
67193ff5c4
@ -253,6 +253,8 @@ int usrsock_setup_request_callback(FAR struct usrsock_conn_s *conn,
|
|||||||
int ret = -EBUSY;
|
int ret = -EBUSY;
|
||||||
|
|
||||||
(void)nxsem_init(&pstate->recvsem, 0, 0);
|
(void)nxsem_init(&pstate->recvsem, 0, 0);
|
||||||
|
nxsem_setprotocol(&pstate->recvsem, SEM_PRIO_NONE);
|
||||||
|
|
||||||
pstate->conn = conn;
|
pstate->conn = conn;
|
||||||
pstate->result = -EAGAIN;
|
pstate->result = -EAGAIN;
|
||||||
pstate->completed = false;
|
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 */
|
/* Make sure that no further events are processed */
|
||||||
|
|
||||||
devif_conn_callback_free(NULL, pstate->cb, &conn->list);
|
devif_conn_callback_free(NULL, pstate->cb, &conn->list);
|
||||||
|
nxsem_destroy(&pstate->recvsem);
|
||||||
|
|
||||||
pstate->cb = NULL;
|
pstate->cb = NULL;
|
||||||
}
|
}
|
||||||
|
@ -274,8 +274,8 @@ static uint8_t usrsockdev_get_xid(FAR struct usrsock_conn_s *conn)
|
|||||||
{
|
{
|
||||||
int conn_idx;
|
int conn_idx;
|
||||||
|
|
||||||
#if CONFIG_NET_USRSOCK_CONNS > 255
|
#if CONFIG_NET_USRSOCK_CONNS > 254
|
||||||
# error "CONFIG_NET_USRSOCK_CONNS too large (over 255)"
|
# error "CONFIG_NET_USRSOCK_CONNS too large (over 254)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Each connection can one only one request/response pending. So map
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
ninfo("usockid=%d; daemon abruptly closed /usr/usrsock.\n", conn->usockid);
|
ninfo("usockid=%d; daemon abruptly closed /usr/usrsock.\n", conn->usockid);
|
||||||
|
ret = -ESHUTDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free request line for next command. */
|
/* 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. */
|
--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.devsem, 0, 1);
|
||||||
nxsem_init(&g_usrsockdev.req.sem, 0, 1);
|
nxsem_init(&g_usrsockdev.req.sem, 0, 1);
|
||||||
nxsem_init(&g_usrsockdev.req.acksem, 0, 0);
|
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);
|
(void)register_driver("/dev/usrsock", &g_usrsockdevops, 0666, &g_usrsockdev);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user