forked from mirrors/kore
TAILQ_FOREACH_SAFE() exists so use it.
This commit is contained in:
parent
7c78dea211
commit
0ea911140e
|
@ -1433,8 +1433,7 @@ cli_buildopt_cleanup(void)
|
|||
struct buildopt *bopt, *next;
|
||||
struct mime_type *mime, *mnext;
|
||||
|
||||
for (bopt = TAILQ_FIRST(&build_options); bopt != NULL; bopt = next) {
|
||||
next = TAILQ_NEXT(bopt, list);
|
||||
TAILQ_FOREACH_SAFE(bopt, &build_options, list, next) {
|
||||
TAILQ_REMOVE(&build_options, bopt, list);
|
||||
|
||||
if (bopt->cflags != NULL)
|
||||
|
@ -1450,8 +1449,7 @@ cli_buildopt_cleanup(void)
|
|||
kore_free(bopt);
|
||||
}
|
||||
|
||||
for (mime = TAILQ_FIRST(&mime_types); mime != NULL; mime = mnext) {
|
||||
mnext = TAILQ_NEXT(mime, list);
|
||||
TAILQ_FOREACH_SAFE(mime, &mime_types, list, mnext) {
|
||||
TAILQ_REMOVE(&mime_types, mime, list);
|
||||
kore_free(mime->type);
|
||||
kore_free(mime->ext);
|
||||
|
|
|
@ -171,15 +171,13 @@ kore_connection_prune(int all)
|
|||
struct connection *c, *cnext;
|
||||
|
||||
if (all) {
|
||||
for (c = TAILQ_FIRST(&connections); c != NULL; c = cnext) {
|
||||
cnext = TAILQ_NEXT(c, list);
|
||||
TAILQ_FOREACH_SAFE(c, &connections, list, cnext) {
|
||||
net_send_flush(c);
|
||||
kore_connection_disconnect(c);
|
||||
}
|
||||
}
|
||||
|
||||
for (c = TAILQ_FIRST(&disconnected); c != NULL; c = cnext) {
|
||||
cnext = TAILQ_NEXT(c, list);
|
||||
TAILQ_FOREACH_SAFE(c, &disconnected, list, cnext) {
|
||||
TAILQ_REMOVE(&disconnected, c, list);
|
||||
kore_connection_remove(c);
|
||||
}
|
||||
|
@ -335,9 +333,7 @@ kore_connection_remove(struct connection *c)
|
|||
kore_free(c->hdlr_extra);
|
||||
|
||||
#if !defined(KORE_NO_HTTP)
|
||||
for (req = TAILQ_FIRST(&(c->http_requests));
|
||||
req != NULL; req = rnext) {
|
||||
rnext = TAILQ_NEXT(req, olist);
|
||||
TAILQ_FOREACH_SAFE(req, &(c->http_requests), olist, rnext) {
|
||||
TAILQ_REMOVE(&(c->http_requests), req, olist);
|
||||
req->owner = NULL;
|
||||
req->flags |= HTTP_REQUEST_DELETE;
|
||||
|
@ -349,8 +345,7 @@ kore_connection_remove(struct connection *c)
|
|||
kore_free(c->ws_disconnect);
|
||||
#endif
|
||||
|
||||
for (nb = TAILQ_FIRST(&(c->send_queue)); nb != NULL; nb = next) {
|
||||
next = TAILQ_NEXT(nb, list);
|
||||
TAILQ_FOREACH_SAFE(nb, &(c->send_queue), list, next) {
|
||||
TAILQ_REMOVE(&(c->send_queue), nb, list);
|
||||
if (!(nb->flags & NETBUF_IS_STREAM)) {
|
||||
kore_free(nb->buf);
|
||||
|
|
26
src/http.c
26
src/http.c
|
@ -320,7 +320,7 @@ http_process(void)
|
|||
struct http_request *req, *next;
|
||||
|
||||
count = 0;
|
||||
for (req = TAILQ_FIRST(&http_requests); req != NULL; req = next) {
|
||||
TAILQ_FOREACH_SAFE(req, &http_requests, list, next) {
|
||||
if (count >= http_request_limit)
|
||||
break;
|
||||
|
||||
|
@ -470,27 +470,21 @@ http_request_free(struct http_request *req)
|
|||
if (req->owner != NULL)
|
||||
TAILQ_REMOVE(&(req->owner->http_requests), req, olist);
|
||||
|
||||
for (hdr = TAILQ_FIRST(&(req->resp_headers)); hdr != NULL; hdr = next) {
|
||||
next = TAILQ_NEXT(hdr, list);
|
||||
|
||||
TAILQ_FOREACH_SAFE(hdr, &(req->resp_headers), list, next) {
|
||||
TAILQ_REMOVE(&(req->resp_headers), hdr, list);
|
||||
kore_free(hdr->header);
|
||||
kore_free(hdr->value);
|
||||
kore_pool_put(&http_header_pool, hdr);
|
||||
}
|
||||
|
||||
for (hdr = TAILQ_FIRST(&(req->req_headers)); hdr != NULL; hdr = next) {
|
||||
next = TAILQ_NEXT(hdr, list);
|
||||
|
||||
TAILQ_FOREACH_SAFE(hdr, &(req->req_headers), list, next) {
|
||||
TAILQ_REMOVE(&(req->req_headers), hdr, list);
|
||||
kore_free(hdr->header);
|
||||
kore_free(hdr->value);
|
||||
kore_pool_put(&http_header_pool, hdr);
|
||||
}
|
||||
|
||||
for (ck = TAILQ_FIRST(&(req->resp_cookies)); ck != NULL; ck = cknext) {
|
||||
cknext = TAILQ_NEXT(ck, list);
|
||||
|
||||
TAILQ_FOREACH_SAFE(ck, &(req->resp_cookies), list, cknext) {
|
||||
TAILQ_REMOVE(&(req->resp_cookies), ck, list);
|
||||
kore_free(ck->name);
|
||||
kore_free(ck->value);
|
||||
|
@ -499,28 +493,22 @@ http_request_free(struct http_request *req)
|
|||
kore_pool_put(&http_cookie_pool, ck);
|
||||
}
|
||||
|
||||
for (ck = TAILQ_FIRST(&(req->req_cookies)); ck != NULL; ck = cknext) {
|
||||
cknext = TAILQ_NEXT(ck, list);
|
||||
|
||||
TAILQ_FOREACH_SAFE(ck, &(req->req_cookies), list, cknext) {
|
||||
TAILQ_REMOVE(&(req->req_cookies), ck, list);
|
||||
kore_free(ck->name);
|
||||
kore_free(ck->value);
|
||||
kore_pool_put(&http_cookie_pool, ck);
|
||||
}
|
||||
|
||||
for (q = TAILQ_FIRST(&(req->arguments)); q != NULL; q = qnext) {
|
||||
qnext = TAILQ_NEXT(q, list);
|
||||
|
||||
TAILQ_FOREACH_SAFE(q, &(req->arguments), list, qnext) {
|
||||
TAILQ_REMOVE(&(req->arguments), q, list);
|
||||
kore_free(q->name);
|
||||
kore_free(q->s_value);
|
||||
kore_free(q);
|
||||
}
|
||||
|
||||
for (f = TAILQ_FIRST(&(req->files)); f != NULL; f = fnext) {
|
||||
fnext = TAILQ_NEXT(f, list);
|
||||
TAILQ_FOREACH_SAFE(f, &(req->files), list, fnext) {
|
||||
TAILQ_REMOVE(&(req->files), f, list);
|
||||
|
||||
kore_free(f->filename);
|
||||
kore_free(f->name);
|
||||
kore_free(f);
|
||||
|
|
|
@ -53,8 +53,7 @@ kore_module_cleanup(void)
|
|||
{
|
||||
struct kore_module *module, *next;
|
||||
|
||||
for (module = TAILQ_FIRST(&modules); module != NULL; module = next) {
|
||||
next = TAILQ_NEXT(module, list);
|
||||
TAILQ_FOREACH_SAFE(module, &modules, list, next) {
|
||||
TAILQ_REMOVE(&modules, module, list);
|
||||
module->fun->free(module);
|
||||
}
|
||||
|
@ -276,8 +275,7 @@ kore_module_handler_free(struct kore_module_handle *hdlr)
|
|||
/* Drop all validators associated with this handler */
|
||||
while ((param = TAILQ_FIRST(&(hdlr->params))) != NULL) {
|
||||
TAILQ_REMOVE(&(hdlr->params), param, list);
|
||||
if (param->name != NULL)
|
||||
kore_free(param->name);
|
||||
kore_free(param->name);
|
||||
kore_free(param);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ kore_pgsql_sys_cleanup(void)
|
|||
kore_pool_cleanup(&pgsql_job_pool);
|
||||
kore_pool_cleanup(&pgsql_wait_pool);
|
||||
|
||||
for (conn = TAILQ_FIRST(&pgsql_conn_free); conn != NULL; conn = next) {
|
||||
next = TAILQ_NEXT(conn, list);
|
||||
TAILQ_FOREACH_SAFE(conn, &pgsql_conn_free, list, next) {
|
||||
pgsql_conn_cleanup(conn);
|
||||
}
|
||||
}
|
||||
|
@ -390,8 +389,7 @@ kore_pgsql_queue_remove(struct http_request *req)
|
|||
{
|
||||
struct pgsql_wait *pgw, *next;
|
||||
|
||||
for (pgw = TAILQ_FIRST(&pgsql_wait_queue); pgw != NULL; pgw = next) {
|
||||
next = TAILQ_NEXT(pgw, list);
|
||||
TAILQ_FOREACH_SAFE(pgw, &pgsql_wait_queue, list, next) {
|
||||
if (pgw->req != req)
|
||||
continue;
|
||||
|
||||
|
@ -481,8 +479,7 @@ pgsql_queue_wakeup(void)
|
|||
{
|
||||
struct pgsql_wait *pgw, *next;
|
||||
|
||||
for (pgw = TAILQ_FIRST(&pgsql_wait_queue); pgw != NULL; pgw = next) {
|
||||
next = TAILQ_NEXT(pgw, list);
|
||||
TAILQ_FOREACH_SAFE(pgw, &pgsql_wait_queue, list, next) {
|
||||
if (pgw->req->flags & HTTP_REQUEST_DELETE)
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue