Commit 4486595b authored by Grigorii Demidov's avatar Grigorii Demidov Committed by Petr Špaček

daemon: kresd fall into endless loop in some circumstances when tls is used; fix

parent 90e397b8
......@@ -869,6 +869,7 @@ int tls_client_push(struct qr_task *task, uv_handle_t *handle, knot_pkt_t *pkt)
return kr_error(EIO);
}
} else {
retries = 0;
submitted += count;
if (count == 0 && submitted != sizeof(pkt_size) + pkt->size) {
kr_log_error("[tls_client] gnutls_record_uncork didn't send all data: %s (%zd)\n",
......
......@@ -804,9 +804,21 @@ static int qr_task_on_send(struct qr_task *task, uv_handle_t *handle, int status
if (session->closing) {
return status;
}
/* Finalize the task, if any errors.
* We can't add it to the end of waiting list for retrying
* since it may lead endless loop in some circumstances
* (for instance: tls; send->tls_push->too many non-critical errors->
* on_send with nonzero status->re-add to waiting->send->etc).*/
if (status != 0) {
/* Add to the end for retry */
session_add_waiting(session, task);
qr_task_finalize(task, KR_STATE_FAIL);
if (session->outgoing) {
qr_task_finalize(task, KR_STATE_FAIL);
} else {
assert(task->ctx->source.session == session);
task->ctx->source.session = NULL;
}
session_del_tasks(session, task);
qr_task_unref(task);
}
if (session->waiting.len > 0) {
struct qr_task *t = session->waiting.at[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment