Don't buffer up multiple outgoing frames

It's pointless to send multiple frames in a single buffer. It just
overloads the client.
tight-png
Andri Yngvason 2019-12-23 12:10:58 +00:00
parent 4ebf4623cb
commit bfb1cd9fc9
1 changed files with 3 additions and 9 deletions

View File

@ -76,7 +76,6 @@ struct nvnc_client {
LIST_ENTRY(nvnc_client) link; LIST_ENTRY(nvnc_client) link;
struct pixman_region16 damage; struct pixman_region16 damage;
int n_pending_requests; int n_pending_requests;
int n_outgoing_frames;
bool is_updating; bool is_updating;
nvnc_client_fn cleanup_fn; nvnc_client_fn cleanup_fn;
z_stream z_stream; z_stream z_stream;
@ -870,7 +869,7 @@ static void on_write_frame_done(uv_write_t* req, int status)
{ {
struct vnc_write_request* rq = (struct vnc_write_request*)req; struct vnc_write_request* rq = (struct vnc_write_request*)req;
struct nvnc_client* client = rq->userdata; struct nvnc_client* client = rq->userdata;
client->n_outgoing_frames--; client->is_updating = false;
free(rq->buffer.base); free(rq->buffer.base);
} }
@ -921,14 +920,12 @@ void on_client_update_fb_done(uv_work_t* work, int status)
struct nvnc* server = client->server; struct nvnc* server = client->server;
struct vec* frame = &update->frame; struct vec* frame = &update->frame;
if (client->n_outgoing_frames <= MAX_OUTGOING_FRAMES && if (!uv_is_closing((uv_handle_t*)&client->stream_handle))
!uv_is_closing((uv_handle_t*)&client->stream_handle))
vnc__write2((uv_stream_t*)&client->stream_handle, frame->data, vnc__write2((uv_stream_t*)&client->stream_handle, frame->data,
frame->len, on_write_frame_done, client); frame->len, on_write_frame_done, client);
else else
client->n_outgoing_frames--; client->is_updating = false;
client->is_updating = false;
client->n_pending_requests--; client->n_pending_requests--;
process_fb_update_requests(client); process_fb_update_requests(client);
nvnc_fb_unref(update->fb); nvnc_fb_unref(update->fb);
@ -961,8 +958,6 @@ int schedule_client_update_fb(struct nvnc_client* client)
client_ref(client); client_ref(client);
nvnc_fb_ref(fb); nvnc_fb_ref(fb);
client->n_outgoing_frames++;
rc = uv_queue_work(uv_default_loop(), &work->work, do_client_update_fb, rc = uv_queue_work(uv_default_loop(), &work->work, do_client_update_fb,
on_client_update_fb_done); on_client_update_fb_done);
if (rc < 0) if (rc < 0)
@ -971,7 +966,6 @@ int schedule_client_update_fb(struct nvnc_client* client)
return 0; return 0;
queue_failure: queue_failure:
client->n_outgoing_frames--;
nvnc_fb_unref(fb); nvnc_fb_unref(fb);
client_unref(client); client_unref(client);
vec_destroy(&work->frame); vec_destroy(&work->frame);