Skip to content

KV parsing rework with newline termination in mind #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2016

Conversation

mazimkhan
Copy link
Contributor

@mazimkhan mazimkhan commented Sep 14, 2016

Key,Value parsing is reworked to separate key,Value protocol format and need to limit request response based on \n. See #104 for context. Also affects #123

Additionally the self.buff was being appended with received strings without being cleared and without being needed as only self.buff_idx onward string was parsed. Looks like a memory leak.

@mazimkhan
Copy link
Contributor Author

mazimkhan commented Sep 14, 2016

@bridadan @adbridge please review.

self.buff += payload
lines = self.buff.split('\n')
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're now explicitly adding '\r' in ARMmbed/mbed-os#2702, is there a place where this character can be handled and stripped in this PR?

Ideally the next release of htrun should be able to handle cases where the '\r' is or is not present, since the tool may be used with older releases of mbed OS.

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd probably fine just to do a rstrip on the returned line before inserting it into the kvl list: https://docs.python.org/2/library/string.html#string.rstrip

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since \n is removed from K,V regex any character outside the K.V pattern does not affect us. I have tested it. It works with mbed-os master and ARMmbed/mbed-os#2702

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we extract key and value using the K,V regex we don't need any extra processing like rstrip.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see @mazimkhan, thanks for explaining. Totally missed that the first time around 😄

@bridadan
Copy link
Contributor

Changes seem ok to me besides my comments. The main thing I thing we have to be careful of with this PR is not breaking compatibility with older releases

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

:shipit: (<- apparently this means "ship it", look how hip I am!)

@mazimkhan mazimkhan merged commit ffa90db into ARMmbed:master Sep 15, 2016
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