kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 82a9e6ef593c9866f7976c3b9574bf2026005171
parent f4d00645ed078f4e8ddd883d37303e517d605bc8
Author: Joris Vink <joris@coders.se>
Date:   Mon,  1 Feb 2016 20:02:02 +0100

Formatting and unbreaking NOHTTP builds.

Diffstat:
src/bsd.c | 2+-
src/domain.c | 59+++++++++++++++++++++++++++--------------------------------
src/kore.c | 2+-
src/linux.c | 2+-
src/module.c | 35++++++++++++++++-------------------
src/pool.c | 7+------
6 files changed, 47 insertions(+), 60 deletions(-)

diff --git a/src/bsd.c b/src/bsd.c @@ -97,7 +97,7 @@ kore_platform_event_init(void) void kore_platform_event_cleanup(void) { - if (kfd >= 0) { + if (kfd != -1) { close(kfd); kfd = -1; } diff --git a/src/domain.c b/src/domain.c @@ -47,7 +47,7 @@ kore_domain_cleanup(void) { struct kore_domain *dom; - while ((dom=TAILQ_FIRST(&domains)) != NULL) { + while ((dom = TAILQ_FIRST(&domains)) != NULL) { TAILQ_REMOVE(&domains, dom, list); kore_domain_free(dom); } @@ -85,44 +85,41 @@ kore_domain_new(char *domain) void kore_domain_free(struct kore_domain *dom) { +#if !defined(KORE_NO_HTTP) struct kore_module_handle *hdlr; +#endif + if (dom == NULL) + return; - if (dom != NULL) { + if (primary_dom == dom) + primary_dom = NULL; - if (primary_dom == dom) { - primary_dom = NULL; - } - TAILQ_REMOVE(&domains, dom, list); + TAILQ_REMOVE(&domains, dom, list); - if (dom->domain != NULL) { - kore_mem_free(dom->domain); - } + if (dom->domain != NULL) + kore_mem_free(dom->domain); #if !defined(KORE_NO_TLS) - if (dom->ssl_ctx != NULL) { - SSL_CTX_free(dom->ssl_ctx); - } - if (dom->cafile != NULL) { - kore_mem_free(dom->cafile); - } - if (dom->certkey != NULL) { - kore_mem_free(dom->certkey); - } - if (dom->certfile != NULL) { - kore_mem_free(dom->certfile); - } - if (dom->crlfile != NULL) { - kore_mem_free(dom->crlfile); - } + if (dom->ssl_ctx != NULL) + SSL_CTX_free(dom->ssl_ctx); + if (dom->cafile != NULL) + kore_mem_free(dom->cafile); + if (dom->certkey != NULL) + kore_mem_free(dom->certkey); + if (dom->certfile != NULL) + kore_mem_free(dom->certfile); + if (dom->crlfile != NULL) + kore_mem_free(dom->crlfile); #endif - /* Drop all handlers associated with this domain */ - while ((hdlr=TAILQ_FIRST(&(dom->handlers))) != NULL) { - TAILQ_REMOVE(&(dom->handlers), hdlr, list); - kore_module_handler_free(hdlr); - } - kore_mem_free(dom); +#if !defined(KORE_NO_HTTP) + /* Drop all handlers associated with this domain */ + while ((hdlr = TAILQ_FIRST(&(dom->handlers))) != NULL) { + TAILQ_REMOVE(&(dom->handlers), hdlr, list); + kore_module_handler_free(hdlr); } +#endif + kore_mem_free(dom); } void @@ -233,9 +230,7 @@ kore_domain_sslstart(struct kore_domain *dom) SSL_CTX_set_tlsext_servername_callback(dom->ssl_ctx, kore_tls_sni_cb); kore_mem_free(dom->certfile); - dom->certfile = NULL; kore_mem_free(dom->certkey); - dom->certkey = NULL; #endif } diff --git a/src/kore.c b/src/kore.c @@ -421,7 +421,7 @@ kore_server_start(void) kore_platform_event_cleanup(); kore_connection_cleanup(); - kore_domain_cleanup(); + kore_domain_cleanup(); net_cleanup(); } diff --git a/src/linux.c b/src/linux.c @@ -74,7 +74,7 @@ kore_platform_event_init(void) void kore_platform_event_cleanup(void) { - if (efd >= 0) { + if (efd != -1) { close(efd); efd = -1; } diff --git a/src/module.c b/src/module.c @@ -201,28 +201,25 @@ kore_module_handler_free(struct kore_module_handle *hdlr) { struct kore_handler_params *param; - if (hdlr != NULL) { - if (hdlr->func != NULL) { - kore_mem_free(hdlr->func); - } - if (hdlr->path != NULL) { - kore_mem_free(hdlr->path); - } - if (hdlr->dom != NULL) { - TAILQ_REMOVE(&(hdlr->dom->handlers), hdlr, list); - } + if (hdlr == NULL) + return; + + if (hdlr->func != NULL) + kore_mem_free(hdlr->func); + if (hdlr->path != NULL) + kore_mem_free(hdlr->path); + if (hdlr->type == HANDLER_TYPE_DYNAMIC) regfree(&(hdlr->rctx)); - /* 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_mem_free(param->name); - } - kore_mem_free(param); - } - kore_mem_free(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_mem_free(param->name); + kore_mem_free(param); } + + kore_mem_free(hdlr); } struct kore_module_handle * diff --git a/src/pool.c b/src/pool.c @@ -45,11 +45,6 @@ kore_pool_init(struct kore_pool *pool, const char *name, void kore_pool_cleanup(struct kore_pool *pool) { - if (pool->inuse) - kore_debug("Pool %s: destroyed with %u allocs in use", - pool->name ? pool->name : "<unknown>", - pool->inuse ); - pool->elms = 0; pool->inuse = 0; pool->elen = 0; @@ -137,7 +132,7 @@ pool_region_create(struct kore_pool *pool, u_int32_t elms) static void pool_region_destroy(struct kore_pool *pool) { - struct kore_pool_region *reg; + struct kore_pool_region *reg; kore_debug("pool_region_destroy(%p)", pool);