log: websocket: Avoid byte drop for long messages
In case the log message length exceeded the websocket buffer size, the backend would drop the overflowing character, instead of sending it as a part of the next message. Rework the ws_console_out() logic a bit to prevent that. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
224ffca819
commit
02b5ec62c7
1 changed files with 10 additions and 8 deletions
|
|
@ -66,17 +66,19 @@ static int ws_console_out(struct log_backend_ws_ctx *ctx, int c)
|
|||
unsigned int cnt = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (pos >= (sizeof(output_buf) - 1)) {
|
||||
printnow = true;
|
||||
__ASSERT_NO_MSG(pos < sizeof(output_buf));
|
||||
|
||||
if ((c != '\n') && (c != '\r')) {
|
||||
output_buf[pos++] = c;
|
||||
} else {
|
||||
if ((c != '\n') && (c != '\r')) {
|
||||
output_buf[pos++] = c;
|
||||
} else {
|
||||
printnow = true;
|
||||
}
|
||||
printnow = true;
|
||||
}
|
||||
|
||||
if (printnow) {
|
||||
if (pos >= sizeof(output_buf)) {
|
||||
printnow = true;
|
||||
}
|
||||
|
||||
if (pos > 0 && printnow) {
|
||||
while (ctx->sock >= 0 && cnt < max_cnt) {
|
||||
ret = ws_send_all(ctx->sock, output_buf, pos);
|
||||
if (ret < 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue