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

daemon: improved error handling

parent a8f2f543
Pipeline #35374 passed with stages
in 8 minutes and 6 seconds
......@@ -280,11 +280,11 @@ int tls_process(struct worker_ctx *worker, uv_stream_t *handle, const uint8_t *b
int err = gnutls_handshake(tls_p->tls_session);
if (err == GNUTLS_E_SUCCESS) {
tls_p->handshake_state = TLS_HS_DONE;
kr_log_verbose("[%s] TLS handshake with %s has completed\n",
logstring, kr_straddr(&session->peer.ip));
if (tls_p->handshake_cb) {
tls_p->handshake_cb(tls_p->session, 0);
}
kr_log_verbose("[%s] TLS handshake with %s has completed\n",
logstring, kr_straddr(&session->peer.ip));
} else if (err == GNUTLS_E_AGAIN) {
return 0;
} else if (gnutls_error_is_fatal(err)) {
......
......@@ -1080,29 +1080,31 @@ static int session_tls_hs_cb(struct session *session, int status)
kr_nsrep_update_rtt(NULL, &peer->ip, KR_NS_DEAD,
worker->engine->resolver.cache_rtt,
KR_NS_UPDATE_NORESET);
return kr_ok();
}
int ret = worker_add_tcp_connected(worker, &peer->ip, session);
if (deletion_res == kr_ok() && ret == kr_ok()) {
ret = session_next_waiting_send(session);
} else {
if (deletion_res != 0) {
/* session isn't in list of waiting queries, *
* something gone wrong */
while (session->waiting.len > 0) {
struct qr_task *task = session->waiting.at[0];
session_del_tasks(session, task);
array_del(session->waiting, 0);
qr_task_finalize(task, KR_STATE_FAIL);
qr_task_unref(task);
}
assert(session->tasks.len == 0);
session_close(session);
return kr_ok();
}
ret = kr_error(EINVAL);
}
int ret = session_next_waiting_send(session);
if (ret == kr_ok()) {
struct worker_ctx *worker = get_worker();
union inaddr *peer = &session->peer;
int ret = worker_add_tcp_connected(worker, &peer->ip, session);
assert(ret == 0);
if (ret != kr_ok()) {
/* Something went wrong.
* Session isn't in the list of waiting sessions,
* or addition to the list of connected sessions failed,
* or write to upstream failed. */
while (session->waiting.len > 0) {
struct qr_task *task = session->waiting.at[0];
session_del_tasks(session, task);
array_del(session->waiting, 0);
qr_task_finalize(task, KR_STATE_FAIL);
qr_task_unref(task);
}
worker_del_tcp_connected(worker, &peer->ip);
assert(session->tasks.len == 0);
session_close(session);
}
return kr_ok();
}
......
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