refactor: panic on full router

master
Sean McBride 3 years ago
parent 4d0da84ffb
commit 022510950f

@ -30,7 +30,7 @@ http_router_add_route(struct http_router *router, struct route_config *config, s
assert(module != NULL); assert(module != NULL);
assert(config->route != NULL); assert(config->route != NULL);
assert(config->http_resp_content_type != NULL); assert(config->http_resp_content_type != NULL);
assert(router->routes_length <= HTTP_ROUTER_ROUTES_CAPACITY); assert(router->routes_length < HTTP_ROUTER_ROUTES_CAPACITY);
if (unlikely(router->routes_length == HTTP_ROUTER_ROUTES_CAPACITY)) { return -1; } if (unlikely(router->routes_length == HTTP_ROUTER_ROUTES_CAPACITY)) { return -1; }

@ -46,7 +46,12 @@ tenant_alloc(struct tenant_config *config)
assert(module != NULL); assert(module != NULL);
/* Ownership of config's route and http_resp_content_type move here */ /* Ownership of config's route and http_resp_content_type move here */
http_router_add_route(&tenant->router, &config->routes[i], module); int rc = http_router_add_route(&tenant->router, &config->routes[i], module);
if (unlikely(rc != 0)) {
panic("Tenant %s defined %lu routes, but router could only hold %d\n", tenant->name,
config->routes_len, HTTP_ROUTER_ROUTES_CAPACITY);
}
config->routes[i].route = NULL; config->routes[i].route = NULL;
config->routes[i].http_resp_content_type = NULL; config->routes[i].http_resp_content_type = NULL;
} }

Loading…
Cancel
Save