Permalink
Browse files

Merge branch 'release/1.1.6'

  • Loading branch information...
Mark Ellzey
Mark Ellzey committed Oct 24, 2012
2 parents 921248d + 0019735 commit 91071e2f20749cd469b87ac2ef1c158dc2a6806f
Showing with 94 additions and 59 deletions.
  1. +1 −1 CMakeLists.txt
  2. +8 −0 ChangeLog
  3. +47 −33 evhtp.c
  4. +6 −2 evhtp.h
  5. +8 −0 evthr/evthr.h
  6. +24 −23 htparse/htparse.c
View
@@ -3,7 +3,7 @@ project(reason)
set(PROJECT_MAJOR_VERSION 1)
set(PROJECT_MINOR_VERSION 1)
-set(PROJECT_PATCH_VERSION 5)
+set(PROJECT_PATCH_VERSION 6)
set (PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
View
@@ -1,3 +1,11 @@
+v1.1.6
+ o Added __cplusplus into evthr (31e3973 Mark Ellzey)
+ o Use evhtp_hook_generic_cb function pointer prototype when setting a hook (59f01f3 Gian-Paolo Musumeci)
+ o ISO C fixes. (d1627f7 Mark Ellzey)
+ o ISO C fixes. (5be2662 Mark Ellzey)
+ o Renaming evhtp_hook_generic_cb to evhtp_hook, more ISO compliance. (60b3502 Mark Ellzey)
+ o Removing strict flags from BaseConfig. (bdc6265 Mark Ellzey)
+
v1.1.5
o Don't treat non hex chars as errors. (d8c584d Mark Ellzey)
o If non hex, replace idx-1 with % (2783983 Mark Ellzey)
View
80 evhtp.c
@@ -87,9 +87,9 @@ static void _evhtp_path_free(evhtp_path_t * path);
#endif
#ifndef TAILQ_FOREACH_SAFE
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = TAILQ_FIRST((head)); \
+ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar))
#endif
@@ -115,7 +115,7 @@ status_code_cmp(void * _a, void * _b) {
}
RB_HEAD(status_code_tree, status_code) status_code_head = RB_INITIALIZER(&status_code_head);
-RB_GENERATE(status_code_tree, status_code, entry, status_code_cmp);
+RB_GENERATE(status_code_tree, status_code, entry, status_code_cmp)
#define scode_add(scode, cstr) do { \
struct status_code * c = malloc(sizeof(struct status_code)); \
@@ -1329,7 +1329,7 @@ _evhtp_connection_resumecb(int fd, short events, void * arg) {
c->request->status = EVHTP_RES_OK;
}
- return _evhtp_connection_readcb(c->bev, c);
+ _evhtp_connection_readcb(c->bev, c);
}
static void
@@ -1360,7 +1360,8 @@ _evhtp_connection_readcb(evbev_t * bev, void * arg) {
* drain the input buffer that had been read up to this point.
*/
evbuffer_drain(bufferevent_get_input(bev), nread);
- return evhtp_connection_free(c);
+ evhtp_connection_free(c);
+ return;
}
if (c->request) {
@@ -1369,7 +1370,8 @@ _evhtp_connection_readcb(evbev_t * bev, void * arg) {
if (c->request->hooks && c->request->hooks->on_error) {
(*c->request->hooks->on_error)(c->request, -1, c->request->hooks->on_error_arg);
}
- return evhtp_connection_free(c);
+ evhtp_connection_free(c);
+ return;
default:
break;
}
@@ -1379,7 +1381,8 @@ _evhtp_connection_readcb(evbev_t * bev, void * arg) {
if (c->request && c->request->status == EVHTP_RES_PAUSE) {
evhtp_request_pause(c->request);
} else {
- return evhtp_connection_free(c);
+ evhtp_connection_free(c);
+ return;
}
}
@@ -1429,9 +1432,11 @@ _evhtp_connection_writecb(evbev_t * bev, void * arg) {
htparser_init(c->parser, htp_type_request);
- return htparser_set_userdata(c->parser, c);
+ htparser_set_userdata(c->parser, c);
+ return;
} else {
- return evhtp_connection_free(c);
+ evhtp_connection_free(c);
+ return;
}
return;
@@ -1463,7 +1468,7 @@ _evhtp_connection_eventcb(evbev_t * bev, short events, void * arg) {
c->request->hooks->on_error_arg);
}
- return evhtp_connection_free((evhtp_connection_t *)arg);
+ evhtp_connection_free((evhtp_connection_t *)arg);
}
static int
@@ -1550,7 +1555,7 @@ _evhtp_connection_accept(evbase_t * evbase, evhtp_connection_t * connection) {
static void
_evhtp_default_request_cb(evhtp_request_t * request, void * arg) {
- return evhtp_send_reply(request, EVHTP_RES_NOTFOUND);
+ evhtp_send_reply(request, EVHTP_RES_NOTFOUND);
}
static evhtp_connection_t *
@@ -1613,11 +1618,13 @@ _evhtp_run_in_thread(evthr_t * thr, void * arg, void * shared) {
evthr_inc_backlog(connection->thread);
if (_evhtp_connection_accept(connection->evbase, connection) < 0) {
- return evhtp_connection_free(connection);
+ evhtp_connection_free(connection);
+ return;
}
if (_evhtp_run_post_accept(htp, connection) < 0) {
- return evhtp_connection_free(connection);
+ evhtp_connection_free(connection);
+ return;
}
}
@@ -1639,19 +1646,22 @@ _evhtp_accept_cb(evserv_t * serv, int fd, struct sockaddr * s, int sl, void * ar
if (htp->thr_pool != NULL) {
if (evthr_pool_defer(htp->thr_pool, _evhtp_run_in_thread, connection) != EVTHR_RES_OK) {
evutil_closesocket(connection->sock);
- return evhtp_connection_free(connection);
+ evhtp_connection_free(connection);
+ return;
}
return;
}
#endif
connection->evbase = htp->evbase;
if (_evhtp_connection_accept(htp->evbase, connection) < 0) {
- return evhtp_connection_free(connection);
+ evhtp_connection_free(connection);
+ return;
}
if (_evhtp_run_post_accept(htp, connection) < 0) {
- return evhtp_connection_free(connection);
+ evhtp_connection_free(connection);
+ return;
}
}
@@ -1817,7 +1827,7 @@ evhtp_connection_resume(evhtp_connection_t * c) {
void
evhtp_request_pause(evhtp_request_t * request) {
request->status = EVHTP_RES_PAUSE;
- return evhtp_connection_pause(request->conn);
+ evhtp_connection_pause(request->conn);
}
/**
@@ -1829,7 +1839,7 @@ evhtp_request_pause(evhtp_request_t * request) {
*/
void
evhtp_request_resume(evhtp_request_t * request) {
- return evhtp_connection_resume(request->conn);
+ evhtp_connection_resume(request->conn);
}
evhtp_header_t *
@@ -2159,11 +2169,11 @@ evhtp_parse_query(const char * query, size_t len) {
query_args = evhtp_query_new();
- if (!(key_buf = malloc(len+1))) {
+ if (!(key_buf = malloc(len + 1))) {
return NULL;
}
- if (!(val_buf = malloc(len+1))) {
+ if (!(val_buf = malloc(len + 1))) {
free(key_buf);
return NULL;
}
@@ -2355,7 +2365,8 @@ evhtp_send_reply_start(evhtp_request_t * request, evhtp_res code) {
c = evhtp_request_get_connection(request);
if (!(reply_buf = _evhtp_create_reply(request, code))) {
- return evhtp_connection_free(c);
+ evhtp_connection_free(c);
+ return;
}
bufferevent_write_buffer(c->bev, reply_buf);
@@ -2375,8 +2386,8 @@ void
evhtp_send_reply_end(evhtp_request_t * request) {
request->finished = 1;
- return _evhtp_connection_writecb(evhtp_request_get_bev(request),
- evhtp_request_get_connection(request));
+ _evhtp_connection_writecb(evhtp_request_get_bev(request),
+ evhtp_request_get_connection(request));
}
void
@@ -2388,7 +2399,8 @@ evhtp_send_reply(evhtp_request_t * request, evhtp_res code) {
request->finished = 1;
if (!(reply_buf = _evhtp_create_reply(request, code))) {
- return evhtp_connection_free(request->conn);
+ evhtp_connection_free(request->conn);
+ return;
}
bufferevent_write_buffer(evhtp_connection_get_bev(c), reply_buf);
@@ -2687,7 +2699,7 @@ evhtp_callbacks_add_callback(evhtp_callbacks_t * cbs, evhtp_callback_t * cb) {
}
int
-evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type, void * cb, void * arg) {
+evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type, evhtp_hook cb, void * arg) {
if (*hooks == NULL) {
if (!(*hooks = calloc(sizeof(evhtp_hooks_t), 1))) {
return -1;
@@ -3090,7 +3102,8 @@ evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * cfg) {
} /* switch */
SSL_CTX_use_certificate_file(htp->ssl_ctx, cfg->pemfile, SSL_FILETYPE_PEM);
- SSL_CTX_use_PrivateKey_file(htp->ssl_ctx, cfg->privfile ? : cfg->pemfile, SSL_FILETYPE_PEM);
+ SSL_CTX_use_PrivateKey_file(htp->ssl_ctx,
+ cfg->privfile ? cfg->privfile : cfg->pemfile, SSL_FILETYPE_PEM);
SSL_CTX_set_session_id_context(htp->ssl_ctx,
(void *)&session_id_context,
@@ -3164,7 +3177,7 @@ evhtp_connection_set_bev(evhtp_connection_t * conn, evbev_t * bev) {
void
evhtp_request_set_bev(evhtp_request_t * request, evbev_t * bev) {
- return evhtp_connection_set_bev(request->conn, bev);
+ evhtp_connection_set_bev(request->conn, bev);
}
evhtp_connection_t *
@@ -3173,9 +3186,9 @@ evhtp_request_get_connection(evhtp_request_t * request) {
}
void
-evhtp_connection_set_timeouts(evhtp_connection_t * c,
- const struct timeval * rtimeo,
- const struct timeval * wtimeo) {
+evhtp_connection_set_timeouts(evhtp_connection_t * c,
+ const struct timeval * rtimeo,
+ const struct timeval * wtimeo) {
if (!c) {
return;
}
@@ -3194,7 +3207,7 @@ evhtp_connection_set_max_body_size(evhtp_connection_t * c, uint64_t len) {
void
evhtp_request_set_max_body_size(evhtp_request_t * req, uint64_t len) {
- return evhtp_connection_set_max_body_size(req->conn, len);
+ evhtp_connection_set_max_body_size(req->conn, len);
}
void
@@ -3239,7 +3252,7 @@ evhtp_connection_free(evhtp_connection_t * connection) {
void
evhtp_request_free(evhtp_request_t * request) {
- return _evhtp_request_free(request);
+ _evhtp_request_free(request);
}
void
@@ -3401,3 +3414,4 @@ evhtp_free(evhtp_t * evhtp) {
free(evhtp);
}
+
View
@@ -130,6 +130,10 @@ typedef enum evhtp_ssl_scache_type evhtp_ssl_scache_type;
typedef void (*evhtp_thread_init_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
typedef void (*evhtp_callback_cb)(evhtp_request_t * req, void * arg);
typedef void (*evhtp_hook_err_cb)(evhtp_request_t * req, evhtp_error_flags errtype, void * arg);
+
+/* Generic hook for passing ISO tests */
+typedef evhtp_res (*evhtp_hook)();
+
typedef evhtp_res (*evhtp_pre_accept_cb)(evhtp_connection_t * conn, void * arg);
typedef evhtp_res (*evhtp_post_accept_cb)(evhtp_connection_t * conn, void * arg);
typedef evhtp_res (*evhtp_hook_header_cb)(evhtp_request_t * req, evhtp_header_t * hdr, void * arg);
@@ -155,7 +159,7 @@ typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid
typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
typedef void * (*evhtp_ssl_scache_init)(evhtp_t *);
-#define EVHTP_VERSION "1.1.5"
+#define EVHTP_VERSION "1.1.6"
#define EVHTP_VERSION_MAJOR 1
#define EVHTP_VERSION_MINOR 1
#define EVHTP_VERSION_PATCH 5
@@ -605,7 +609,7 @@ evhtp_callback_t * evhtp_set_glob_cb(evhtp_t * htp, const char * pattern, evhtp_
*
* @return 0 on success, -1 on error (if hooks is NULL, it is allocated)
*/
-int evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type, void * cb, void * arg);
+int evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type, evhtp_hook cb, void * arg);
/**
View
@@ -10,6 +10,10 @@
#include <event2/event.h>
#include <event2/thread.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
enum evthr_res {
EVTHR_RES_OK = 0,
EVTHR_RES_BACKLOG,
@@ -51,5 +55,9 @@ evthr_res evthr_pool_defer(evthr_pool_t * pool, evthr_cb cb, void * arg);
void evthr_pool_free(evthr_pool_t * pool);
void evthr_pool_set_max_backlog(evthr_pool_t * evthr, int max);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __EVTHR_H__ */
Oops, something went wrong.

0 comments on commit 91071e2

Please sign in to comment.