summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2020-03-04 14:03:32 +0300
committerIgor Sysoev <igor@sysoev.ru>2020-03-04 14:03:32 +0300
commit643d4383fa7db466e1d80c7d8c350da4ec043f2b (patch)
tree298a2c3880426d676c553cb9628038b662fde773 /src
parentb214b7c690f9383f296f3d77dcf26755ec00bac3 (diff)
downloadunit-643d4383fa7db466e1d80c7d8c350da4ec043f2b.tar.gz
unit-643d4383fa7db466e1d80c7d8c350da4ec043f2b.tar.bz2
Refactored nxt_http_action.
Diffstat (limited to '')
-rw-r--r--src/nxt_http_route.c28
-rw-r--r--src/nxt_router.c8
-rw-r--r--src/nxt_router.h4
3 files changed, 19 insertions, 21 deletions
diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c
index 05eaa6d4..df52894a 100644
--- a/src/nxt_http_route.c
+++ b/src/nxt_http_route.c
@@ -203,8 +203,8 @@ static void nxt_http_route_resolve(nxt_task_t *task,
nxt_router_temp_conf_t *tmcf, nxt_http_route_t *route);
static void nxt_http_action_resolve(nxt_task_t *task,
nxt_router_temp_conf_t *tmcf, nxt_http_action_t *action);
-static nxt_http_route_t *nxt_http_route_find(nxt_http_routes_t *routes,
- nxt_str_t *name);
+static void nxt_http_route_find(nxt_http_routes_t *routes, nxt_str_t *name,
+ nxt_http_action_t *action);
static void nxt_http_route_cleanup(nxt_task_t *task, nxt_http_route_t *routes);
static nxt_http_action_t *nxt_http_route_handler(nxt_task_t *task,
@@ -1111,11 +1111,9 @@ nxt_http_action_resolve(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
name.length -= 13;
name.start += 13;
- action->u.application = nxt_router_listener_application(tmcf, &name);
+ nxt_router_listener_application(tmcf, &name, action);
nxt_router_app_use(task, action->u.application, 1);
- action->handler = nxt_http_application_handler;
-
} else if (nxt_str_start(&name, "routes", 6)) {
if (name.length == 6) {
@@ -1127,15 +1125,14 @@ nxt_http_action_resolve(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
name.start += 7;
}
- action->u.route = nxt_http_route_find(tmcf->router_conf->routes, &name);
-
- action->handler = nxt_http_route_handler;
+ nxt_http_route_find(tmcf->router_conf->routes, &name, action);
}
}
-static nxt_http_route_t *
-nxt_http_route_find(nxt_http_routes_t *routes, nxt_str_t *name)
+static void
+nxt_http_route_find(nxt_http_routes_t *routes, nxt_str_t *name,
+ nxt_http_action_t *action)
{
nxt_http_route_t **route, **end;
@@ -1144,13 +1141,14 @@ nxt_http_route_find(nxt_http_routes_t *routes, nxt_str_t *name)
while (route < end) {
if (nxt_strstr_eq(&(*route)->name, name)) {
- return *route;
+ action->u.route = *route;
+ action->handler = nxt_http_route_handler;
+
+ return;
}
route++;
}
-
- return NULL;
}
@@ -1191,11 +1189,9 @@ nxt_http_pass_application(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
action->name = *name;
- action->u.application = nxt_router_listener_application(tmcf, name);
+ nxt_router_listener_application(tmcf, name, action);
nxt_router_app_use(task, action->u.application, 1);
- action->handler = nxt_http_application_handler;
-
return action;
}
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 6ef4ee78..46a6b921 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -1904,8 +1904,9 @@ nxt_router_app_find(nxt_queue_t *queue, nxt_str_t *name)
}
-nxt_app_t *
-nxt_router_listener_application(nxt_router_temp_conf_t *tmcf, nxt_str_t *name)
+void
+nxt_router_listener_application(nxt_router_temp_conf_t *tmcf, nxt_str_t *name,
+ nxt_http_action_t *action)
{
nxt_app_t *app;
@@ -1915,7 +1916,8 @@ nxt_router_listener_application(nxt_router_temp_conf_t *tmcf, nxt_str_t *name)
app = nxt_router_app_find(&tmcf->previous, name);
}
- return app;
+ action->u.application = app;
+ action->handler = nxt_http_application_handler;
}
diff --git a/src/nxt_router.h b/src/nxt_router.h
index 1517c14b..9ce9f3be 100644
--- a/src/nxt_router.h
+++ b/src/nxt_router.h
@@ -218,8 +218,8 @@ void nxt_router_access_log_reopen_handler(nxt_task_t *task,
void nxt_router_process_http_request(nxt_task_t *task, nxt_http_request_t *r,
nxt_app_t *app);
void nxt_router_app_port_close(nxt_task_t *task, nxt_port_t *port);
-nxt_app_t *nxt_router_listener_application(nxt_router_temp_conf_t *tmcf,
- nxt_str_t *name);
+void nxt_router_listener_application(nxt_router_temp_conf_t *tmcf,
+ nxt_str_t *name, nxt_http_action_t *action);
void nxt_router_app_use(nxt_task_t *task, nxt_app_t *app, int i);
void nxt_router_listen_event_release(nxt_task_t *task, nxt_listen_event_t *lev,
nxt_socket_conf_joint_t *joint);