kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit b234b7ed655db9c220bbf3fb2aa3ee60bfde4c31
parent eb235b3e019c8099e8c542d2451ce121709def47
Author: Joris Vink <joris@coders.se>
Date:   Fri, 27 Mar 2015 23:23:21 +0100

Add HTTP_REQUEST_RETAIN_EXTRA flag to http_request

Signals Kore to not free any pointer set in req->hdlr_extra.
Useful in certain scenarios where you have data per request
bound to something in memory but do not want to lose it when
the request is freed by Kore.

Set this flag before your handler returns.

Diffstat:
examples/integers/conf/integers.conf | 3+++
includes/http.h | 1+
src/http.c | 3++-
3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/integers/conf/integers.conf b/examples/integers/conf/integers.conf @@ -3,6 +3,9 @@ bind 127.0.0.1 8888 load ./integers.so +workers 2 +worker_max_connections 5000 + ssl_dhparam dh2048.pem validator v_id regex ^-?[0-9]*$ diff --git a/includes/http.h b/includes/http.h @@ -161,6 +161,7 @@ struct http_file { #define HTTP_REQUEST_SLEEPING 0x04 #define HTTP_REQUEST_PGSQL_QUEUE 0x10 #define HTTP_REQUEST_EXPECT_BODY 0x20 +#define HTTP_REQUEST_RETAIN_EXTRA 0x40 struct kore_task; diff --git a/src/http.c b/src/http.c @@ -428,7 +428,8 @@ http_request_free(struct http_request *req) if (req->agent != NULL) kore_mem_free(req->agent); - if (req->hdlr_extra != NULL) + if (req->hdlr_extra != NULL && + !(req->flags & HTTP_REQUEST_RETAIN_EXTRA)) kore_mem_free(req->hdlr_extra); kore_pool_put(&http_request_pool, req);