net/netlink/netlink_conn.c: Fix some really basic errors in the redesign of the asynchronous Netlink response logic.

This commit is contained in:
Gregory Nutt 2019-11-28 16:14:59 -06:00
parent c4d10de565
commit 16b1c276bd
2 changed files with 10 additions and 49 deletions

View File

@ -45,7 +45,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <queue.h> #include <queue.h>
#include <semaphore.h> #include <semaphore.h>
#include <signal.h>
#include <poll.h> #include <poll.h>
#include <netpacket/netlink.h> #include <netpacket/netlink.h>
@ -296,12 +295,12 @@ bool netlink_check_response(FAR struct socket *psock);
* Name: netlink_notify_response * Name: netlink_notify_response
* *
* Description: * Description:
* Notify a thread until a response be available. The thread will be * Notify a thread when a response is available. The thread will be
* notified via work queue notifier when the response becomes available. * notified via work queue notifier when the response becomes available.
* *
* Returned Value: * Returned Value:
* Zero (OK) is returned if the response is already available. Not signal * Zero (OK) is returned if the response is already available. No
* will be sent. * notification will be sent.
* One is returned if the notification was successfully setup. * One is returned if the notification was successfully setup.
* A negated errno value is returned on any failure. * A negated errno value is returned on any failure.
* *

View File

@ -431,28 +431,9 @@ FAR struct netlink_response_s *
} }
else else
{ {
/* Call netlink_notify_response() to receive a notification /* Wait for a response to be queued */
* when a response has been queued.
*/
ret = netlink_notify_response(psock); _netlink_semtake(&waitsem);
if (ret < 0)
{
nerr("ERROR: netlink_notify_response() failed: %d\n", ret);
}
else if (ret == 0)
{
/* The return value of zero means that a response is
* already available and that no notification is
* forthcoming.
*/
}
else
{
/* Otherwise, we have to wait */
_netlink_semtake(&waitsem);
}
} }
/* Clean-up the semaphore */ /* Clean-up the semaphore */
@ -502,12 +483,12 @@ bool netlink_check_response(FAR struct socket *psock)
* Name: netlink_notify_response * Name: netlink_notify_response
* *
* Description: * Description:
* Notify a thread until a response be available. The thread will be * Notify a thread when a response is available. The thread will be
* notified via work queue notifier when the response becomes available. * notified via work queue notifier when the response becomes available.
* *
* Returned Value: * Returned Value:
* Zero (OK) is returned if the response is already available. Not signal * Zero (OK) is returned if the response is already available. No
* will be sent. * notification will be sent.
* One is returned if the notification was successfully setup. * One is returned if the notification was successfully setup.
* A negated errno value is returned on any failure. * A negated errno value is returned on any failure.
* *
@ -545,28 +526,9 @@ int netlink_notify_response(FAR struct socket *psock)
} }
else else
{ {
/* Call netlink_notify_response() to receive a notification /* Wait for a reponse to be queued */
* when a response has been queued.
*/
ret = netlink_notify_response(psock); _netlink_semtake(&waitsem);
if (ret < 0)
{
nerr("ERROR: netlink_notify_response() failed: %d\n", ret);
}
else if (ret == 0)
{
/* The return value of zero means that a response is
* already available and that no notification is
* forthcoming.
*/
}
else
{
/* Otherwise, we have to wait */
_netlink_semtake(&waitsem);
}
} }
/* Tear-down the notifier and the semaphore */ /* Tear-down the notifier and the semaphore */