Browse Source

MT#55283 reverse loop skip logic

Removes one level of indentation for prettier code. Functional no-op.

Change-Id: I5f5528944f144499540f34bc1f322d00c9454fa6
(cherry picked from commit cb9ec2abf9)
mr10.5.4
Richard Fuchs 3 years ago
parent
commit
59b3e664b5
1 changed files with 24 additions and 21 deletions
  1. +24
    -21
      daemon/websocket.c

+ 24
- 21
daemon/websocket.c View File

@ -230,28 +230,31 @@ static int websocket_dequeue(struct websocket_conn *wc) {
struct lws *wsi = wc->wsi;
while ((wo = g_queue_pop_head(&wc->output_q))) {
// used buffer slot?
if (wo->str) {
// allocate post-buffer
g_string_set_size(wo->str, wo->str->len + LWS_SEND_BUFFER_POST_PADDING);
size_t to_send = wo->str->len - wo->str_done - LWS_SEND_BUFFER_POST_PADDING;
if (to_send) {
if (to_send > 2000)
ilogs(http, LOG_DEBUG, "Writing %lu bytes to LWS", (unsigned long) to_send);
else
ilogs(http, LOG_DEBUG, "Writing back to LWS: '%.*s'",
(int) to_send, wo->str->str + wo->str_done);
size_t ret = lws_write(wsi, (unsigned char *) wo->str->str + wo->str_done,
to_send, wo->protocol);
if (ret != to_send)
ilogs(http, LOG_ERR, "Invalid LWS write: %lu != %lu",
(unsigned long) ret,
(unsigned long) to_send);
wo->str_done += ret;
if (wo->protocol == LWS_WRITE_HTTP)
is_http = 1;
}
if (!wo->str)
goto next;
// allocate post-buffer
g_string_set_size(wo->str, wo->str->len + LWS_SEND_BUFFER_POST_PADDING);
size_t to_send = wo->str->len - wo->str_done - LWS_SEND_BUFFER_POST_PADDING;
if (to_send) {
if (to_send > 2000)
ilogs(http, LOG_DEBUG, "Writing %lu bytes to LWS", (unsigned long) to_send);
else
ilogs(http, LOG_DEBUG, "Writing back to LWS: '%.*s'",
(int) to_send, wo->str->str + wo->str_done);
size_t ret = lws_write(wsi, (unsigned char *) wo->str->str + wo->str_done,
to_send, wo->protocol);
if (ret != to_send)
ilogs(http, LOG_ERR, "Invalid LWS write: %lu != %lu",
(unsigned long) ret,
(unsigned long) to_send);
wo->str_done += ret;
if (wo->protocol == LWS_WRITE_HTTP)
is_http = 1;
}
next:
websocket_output_free(wo);
}
g_queue_push_tail(&wc->output_q, websocket_output_new());


Loading…
Cancel
Save