mm/iob: iob_navail() was returning the number of free IOB chain queue entries, not the number of free IOBs. Completely misnamed.

This commit is contained in:
Gregory Nutt
2018-09-12 06:38:11 -06:00
parent a680553f35
commit 76eec53e4f
5 changed files with 68 additions and 7 deletions
+2 -1
View File
@@ -39,6 +39,7 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <semaphore.h>
#include <assert.h>
#include <debug.h>
@@ -148,7 +149,7 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob)
* for an IOB.
*/
if (iob_navail() > 0)
if (iob_navail(false) > 0)
{
/* Signal any threads that have requested a signal notification
* when an IOB becomes available.
+50 -3
View File
@@ -39,6 +39,8 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <nuttx/semaphore.h>
#include <nuttx/mm/iob.h>
@@ -56,17 +58,62 @@
*
****************************************************************************/
int iob_navail(void)
int iob_navail(bool throttled)
{
int navail = 0;
int ret;
#if CONFIG_IOB_NCHAINS > 0
ret = nxsem_getvalue(&g_qentry_sem, &navail);
#if CONFIG_IOB_NBUFFERS > 0
/* Get the value of the IOB counting semaphores */
ret = nxsem_getvalue(&g_iob_sem, &navail);
if (ret >= 0)
{
ret = navail;
#if CONFIG_IOB_THROTTLE > 0
/* Subtract the throttle value is so requested */
if (throttled)
{
ret -= CONFIG_IOB_THROTTLE;
if (ret < 0)
{
ret = 0;
}
}
#endif
}
#else
ret = navail;
#endif
return ret;
}
/****************************************************************************
* Name: iob_quentry_navail
*
* Description:
* Return the number of available IOB chains.
*
****************************************************************************/
int iob_quentry_navail(void)
{
int navail = 0;
int ret;
#if CONFIG_IOB_NCHAINS > 0
/* Get the value of the IOB chain qentry counting semaphores */
ret = nxsem_getvalue(&g_qentry_sem, &navail);
if (ret >= 0)
{
ret = navail;
}
#else
ret = navail;
#endif
+3 -1
View File
@@ -86,9 +86,11 @@ int iob_notifier_setup(int qid, worker_t worker, FAR void *arg)
/* If there are already free IOBs, then return zero without setting up the
* notification.
*
* REVISIT: The 'throttled' argument should not always be 'false'.
*/
if (iob_navail() > 0)
if (iob_navail(false) > 0)
{
return 0;
}