Skip to content

failed to send a long data ( > 512bytes ) #60

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

Closed
etakata opened this issue Jan 27, 2022 · 3 comments · Fixed by #61
Closed

failed to send a long data ( > 512bytes ) #60

etakata opened this issue Jan 27, 2022 · 3 comments · Fixed by #61
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@etakata
Copy link
Contributor

etakata commented Jan 27, 2022

Hello team,

I failed to send a long data(> 512bytes), using BearSSLClient::write(const uint8_t *buf, size_t size)

Suppose that buf stored 600 bytes data and br_sslio_write() could send 512 bytes at maximum each call.

Call write(buf, 600)

Expected behavior
write() sends 600 bytes and returns 600

Current behavior
write() sends 1024 bytes and returns 1024

Detail:

  1. User calls write(buf, 600)
  2. First time execution in the while loop
    • br_sslio_write() sends 512 bytes from &buf[0] and returns 512, buf points at &buf[512], written = 512
  3. written < size is true
  4. Second time execution in the while loop
    • br_sslio_write() sends 512 bytes from &buf[512] and returns 512, buf points at &buf[1024], written = 1024
  5. written < size is false and escaping from the loop
  6. write() returns 1024

To fix this issue, I'd like to change here
from:
int result = br_sslio_write(&_ioc, buf, size);
to:
int result = br_sslio_write(&_ioc, buf, size - written);

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Jan 27, 2022
@aentinger
Copy link
Contributor

Approved 👍 Can you please prepare a PR?

CC @pennam might be worth to integrate this change over at the ArduinoIoTCloud stack.

@etakata
Copy link
Contributor Author

etakata commented Jan 28, 2022

@aentinger

Thank you:)

I opened the pull request.-->#61

@aentinger
Copy link
Contributor

Closing, due to merge of #61.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants