MT#55283 reverse loop skip logic

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

Change-Id: I5f5528944f144499540f34bc1f322d00c9454fa6
pull/1640/head
Richard Fuchs 3 years ago
parent 0914bf761d
commit cb9ec2abf9

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

Loading…
Cancel
Save