Skip to content

Conversation

@simonbeaudoin0935
Copy link
Contributor

@simonbeaudoin0935 simonbeaudoin0935 commented Jul 19, 2020

xStreamBufferSend deadlock avoidance when sending too much data

Description

Add necessary checks when sending data to the stream/message buffer in order to avoid a task deadlock when attempting to write a longer stream/message than the underlying buffer can write.

In the case of the stream buffer, if the user tries to write more bytes than supported, the added code will truncate the stream and adapt the 'xRequiredSpace' variable to the size of the buffer. The user will be able to deal with this scenario by wrapping the call to 'xStreamBufferSend' in appropriate looping code.

In the case of the message buffer, as opposed to stream buffer, there is no choice but to write the whole message (plus a uint32_t for it's length). In this case, the added code will do that 0 will be returned.

A possible touch up to this pull request would be an added error return code for that scenario.

Nevertheless, the deadlock is avoided in both case.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add necessary checks when sending data to the stream/message buffer in order to avoid a task deadlock when attempting to write a longer stream/message than the underlying buffer can write.
@simonbeaudoin0935 simonbeaudoin0935 changed the title Update stream_buffer.c Fix deadlock when writing more bytes to stream buffer than it's size Jul 20, 2020
Copy link
Contributor

@n9wxu n9wxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change only affects the situation where too much is written to the buffer. All current working code should be unaffected by this change.

@n9wxu n9wxu merged commit 61fc74f into FreeRTOS:master Aug 10, 2020
@simonbeaudoin0935
Copy link
Contributor Author

This change only affects the situation where too much is written to the buffer. All current working code should be unaffected by this change.

Exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants