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

View File

@ -195,7 +195,17 @@ FAR struct iob_s *iob_tryalloc(bool throttled);
*
****************************************************************************/
int iob_navail(void);
int iob_navail(bool throttled);
/****************************************************************************
* Name: iob_quentry_navail
*
* Description:
* Return the number of available IOB chains.
*
****************************************************************************/
int iob_quentry_navail(void);
/****************************************************************************
* Name: iob_free

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.

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

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;
}

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#incldue <stdbool.h>
#include <debug.h>
#include <net/if.h>
@ -109,7 +110,7 @@ uint16_t tcp_get_recvwindow(FAR struct net_driver_s *dev)
* availability.
*/
navail = iob_navail();
navail = iob_navail(true);
/* Are the read-ahead allocations throttled? If so, then not all of these
* IOBs are available for read-ahead buffering.