summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conn.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-06-23 19:20:08 +0300
committerMax Romanov <max.romanov@nginx.com>2017-06-23 19:20:08 +0300
commitb8f126dcdfdf04bb01b70f9590fc64b3e155e119 (patch)
tree49fc84fb72e1483103c639e5c394820d8127223f /src/nxt_conn.c
parent4a1b59c27a8e85fc3b03c420fbc1642ce52e96cf (diff)
downloadunit-b8f126dcdfdf04bb01b70f9590fc64b3e155e119.tar.gz
unit-b8f126dcdfdf04bb01b70f9590fc64b3e155e119.tar.bz2
Added basic HTTP request processing in router.
- request to connection mapping in engine; - requests queue in connection; - engine port creation; - connected ports hash for each process; - engine port data messages processing (app responses);
Diffstat (limited to 'src/nxt_conn.c')
-rw-r--r--src/nxt_conn.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/nxt_conn.c b/src/nxt_conn.c
index bba2bfd1..0cc052e8 100644
--- a/src/nxt_conn.c
+++ b/src/nxt_conn.c
@@ -85,6 +85,8 @@ nxt_conn_create(nxt_mp_t *mp, nxt_task_t *task)
nxt_conn_timer_init(&c->read_timer, c, c->socket.read_work_queue);
nxt_conn_timer_init(&c->write_timer, c, c->socket.write_work_queue);
+ nxt_queue_init(&c->requests);
+
nxt_log_debug(&c->log, "connections: %uD", thr->engine->connections);
return c;
@@ -150,3 +152,35 @@ nxt_conn_work_queue_set(nxt_conn_t *c, nxt_work_queue_t *wq)
c->read_timer.work_queue = wq;
c->write_timer.work_queue = wq;
}
+
+
+nxt_req_conn_link_t *
+nxt_conn_request_add(nxt_conn_t *c, nxt_req_id_t req_id)
+{
+ nxt_req_conn_link_t *rc;
+
+ rc = nxt_mp_zalloc(c->mem_pool, sizeof(nxt_req_conn_link_t));
+ if (nxt_slow_path(rc == NULL)) {
+ nxt_thread_log_error(NXT_LOG_WARN, "failed to allocate req %08uxD "
+ "to conn", req_id);
+ return NULL;
+ }
+
+ rc->req_id = req_id;
+ rc->conn = c;
+
+ nxt_queue_insert_tail(&c->requests, &rc->link);
+
+ return rc;
+}
+
+
+void
+nxt_conn_request_remove(nxt_conn_t *c, nxt_req_conn_link_t *rc)
+{
+ nxt_queue_remove(&rc->link);
+
+ nxt_mp_free(c->mem_pool, rc);
+}
+
+