server: Decrement n_pending_requests after dispathing encoding job

The request is as good as handled at that point. We don't want to squeeze
in another frame that the client didn't request before the encoding job
finishes. That would cause a negative pending count and the client would
stop getting updates.
pull/63/head
Andri Yngvason 2022-04-03 20:52:20 +00:00
parent 9d8c956983
commit 3ea068b90c
1 changed files with 3 additions and 3 deletions

View File

@ -661,7 +661,9 @@ static void process_fb_update_requests(struct nvnc_client* client)
client->encoder->on_done = on_encode_frame_done; client->encoder->on_done = on_encode_frame_done;
client->encoder->userdata = client; client->encoder->userdata = client;
if (encoder_encode(client->encoder, fb, &damage) < 0) { if (encoder_encode(client->encoder, fb, &damage) >= 0) {
--client->n_pending_requests;
} else {
log_error("Failed to encode current frame"); log_error("Failed to encode current frame");
client_unref(client); client_unref(client);
client->is_updating = false; client->is_updating = false;
@ -1347,8 +1349,6 @@ static void finish_fb_update(struct nvnc_client* client, struct rcbuf* payload,
client_unref(client); client_unref(client);
} }
client->n_pending_requests--;
DTRACE_PROBE1(neatvnc, update_fb_done, client); DTRACE_PROBE1(neatvnc, update_fb_done, client);
} }