diff --git a/Documentation/reference/os/iob.rst b/Documentation/reference/os/iob.rst index ecb925dc9f..5249139a87 100644 --- a/Documentation/reference/os/iob.rst +++ b/Documentation/reference/os/iob.rst @@ -267,7 +267,8 @@ Public Function Prototypes buffer starting at ``offset`` in the I/O buffer, returning that actual number of bytes copied out. -.. c:function:: int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) +.. c:function:: int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, \ + bool throttled, bool block); Duplicate (and pack) the data in ``iob1`` in ``iob2``. ``iob2`` must be empty. diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index fa672d0cd5..7ced19a487 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -464,8 +464,8 @@ unsigned int iob_tailroom(FAR struct iob_s *iob); * ****************************************************************************/ -int iob_clone(FAR struct iob_s *iob1, - FAR struct iob_s *iob2, bool throttled); +int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, + bool throttled, bool block); /**************************************************************************** * Name: iob_concat diff --git a/mm/iob/iob_clone.c b/mm/iob/iob_clone.c index 1a149bd059..8184d3b3d4 100644 --- a/mm/iob/iob_clone.c +++ b/mm/iob/iob_clone.c @@ -53,7 +53,8 @@ * ****************************************************************************/ -int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) +int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, + bool throttled, bool block) { FAR uint8_t *src; FAR uint8_t *dest; @@ -145,7 +146,15 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled) * destination I/O buffer chain. */ - next = iob_alloc(throttled); + if (block) + { + next = iob_alloc(throttled); + } + else + { + next = iob_tryalloc(throttled); + } + if (!next) { ioberr("ERROR: Failed to allocate an I/O buffer\n");