From: Marek Vavrusa Date: Wed, 11 May 2016 00:11:41 +0000 (-0700) Subject: daemon: renamed is_subreq -> outgoing X-Git-Tag: v1.0.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee19e3a26eca432093605fca0c65bbdd542cde54;p=thirdparty%2Fknot-resolver.git daemon: renamed is_subreq -> outgoing --- diff --git a/daemon/io.c b/daemon/io.c index 439d2a947..ae079140f 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -47,7 +47,7 @@ static void check_bufsize(uv_handle_t* handle) static void session_clear(struct session *s) { - assert(s->is_subreq || s->tasks.len == 0); + assert(s->outgoing || s->tasks.len == 0); array_clear(s->tasks); memset(s, 0, sizeof(*s)); } @@ -112,7 +112,7 @@ static void handle_getbuf(uv_handle_t* handle, size_t suggested_size, uv_buf_t* if (handle->type == UV_TCP) { buf->len = MIN(suggested_size, 4096); /* Regular buffer size for subrequests. */ - } else if (session->is_subreq) { + } else if (session->outgoing) { buf->len = suggested_size; /* Use recvmmsg() on master sockets if possible. */ } else { @@ -186,7 +186,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) worker_end_tcp(worker, (uv_handle_t *)handle); /* Exceeded per-connection quota for outstanding requests * stop reading from stream and close after last message is processed. */ - if (!s->is_subreq && !uv_is_closing((uv_handle_t *)&s->timeout)) { + if (!s->outgoing && !uv_is_closing((uv_handle_t *)&s->timeout)) { uv_timer_stop(&s->timeout); if (s->tasks.len == 0) { uv_close((uv_handle_t *)&s->timeout, tcp_timeout); @@ -195,7 +195,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) } } /* Connection spawned more than one request, reset its deadline for next query. */ - } else if (ret > 0 && !s->is_subreq) { + } else if (ret > 0 && !s->outgoing) { uv_timer_again(&s->timeout); } mp_flush(worker->pkt_pool.ctx); diff --git a/daemon/io.h b/daemon/io.h index 5cdd2de76..bcfa8d680 100644 --- a/daemon/io.h +++ b/daemon/io.h @@ -26,7 +26,7 @@ struct qr_task; * that exists between remote counterpart and a local socket. */ struct session { - bool is_subreq; + bool outgoing; bool throttled; uv_timer_t timeout; struct qr_task *buffering; diff --git a/daemon/worker.c b/daemon/worker.c index 112ce4eb0..055577849 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -109,7 +109,7 @@ static uv_handle_t *ioreq_spawn(struct qr_task *task, int socktype) io_create(task->worker->loop, handle, socktype); /* Set current handle as a subrequest type. */ struct session *session = handle->data; - session->is_subreq = true; + session->outgoing = true; int ret = array_push(session->tasks, task); if (ret != 0) { io_deinit(handle); @@ -756,7 +756,7 @@ int worker_submit(struct worker_ctx *worker, uv_handle_t *handle, knot_pkt_t *ms /* Start new task on listening sockets, or resume if this is subrequest */ struct qr_task *task = NULL; - if (!session->is_subreq) { + if (!session->outgoing) { /* Ignore badly formed queries or responses. */ if (!msg || ret != 0 || knot_wire_get_qr(msg->wire)) { if (msg) worker->stats.dropped += 1; @@ -803,7 +803,7 @@ int worker_end_tcp(struct worker_ctx *worker, uv_handle_t *handle) * because in this case session doesn't own tasks, it has just * borrowed the task from parent session. */ struct session *session = handle->data; - if (session->is_subreq) { + if (session->outgoing) { worker_submit(worker, (uv_handle_t *)handle, NULL, NULL); } else { discard_buffered(session); @@ -836,7 +836,7 @@ int worker_process_tcp(struct worker_ctx *worker, uv_handle_t *handle, const uin /* If this is a new query, create a new task that we can use * to buffer incoming message until it's complete. */ - if (!session->is_subreq) { + if (!session->outgoing) { if (!task) { task = qr_task_create(worker, handle, NULL); if (!task) { @@ -889,7 +889,7 @@ int worker_process_tcp(struct worker_ctx *worker, uv_handle_t *handle, const uin task->bytes_remaining = 0; /* Parse the packet and start resolving complete query */ int ret = parse_packet(pkt_buf); - if (ret == 0 && !session->is_subreq) { + if (ret == 0 && !session->outgoing) { ret = qr_task_start(task, pkt_buf); if (ret != 0) { return ret; @@ -910,7 +910,7 @@ int worker_process_tcp(struct worker_ctx *worker, uv_handle_t *handle, const uin if (ret != 0) { return ret; } - if (len - to_read > 0 && !session->is_subreq) { + if (len - to_read > 0 && !session->outgoing) { ret = worker_process_tcp(worker, handle, msg + to_read, len - to_read); if (ret < 0) { return ret;