Browse Source

Add some missing LI_/li prefixes for types and enum values

personal/stbuehler/wip
Stefan Bühler 11 years ago
parent
commit
b8a0921265
  1. 4
      include/lighttpd/etag.h
  2. 18
      include/lighttpd/typedefs.h
  3. 56
      src/main/actions.c
  4. 4
      src/main/config_parser.rl
  5. 66
      src/main/etag.c
  6. 4
      src/main/virtualrequest.c
  7. 2
      src/modules/mod_balancer.c

4
include/lighttpd/etag.h

@ -5,8 +5,8 @@
#error Please include <lighttpd/base.h> instead of this file
#endif
LI_API tristate_t li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag);
LI_API tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified);
LI_API liTristate li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag);
LI_API liTristate li_http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified);
LI_API gboolean li_http_response_handle_cachable(liVRequest *vr);
/* mut maybe the same as etag */

18
include/lighttpd/typedefs.h

@ -13,7 +13,7 @@ typedef enum {
LI_HANDLER_ERROR
} liHandlerResult;
typedef enum { TRI_FALSE, TRI_MAYBE, TRI_TRUE } tristate_t;
typedef enum { LI_TRIFALSE, LI_TRIMAYBE, LI_TRITRUE } liTristate;
typedef enum { LI_GMTIME, LI_LOCALTIME } liTimeFunc;
typedef enum { LI_TS_FORMAT_DEFAULT, LI_TS_FORMAT_HEADER } liTSFormat;
@ -33,17 +33,17 @@ typedef struct liActionFunc liActionFunc;
typedef struct liBalancerFunc liBalancerFunc;
typedef enum {
ACTION_TSETTING,
ACTION_TSETTINGPTR,
ACTION_TFUNCTION,
ACTION_TCONDITION,
ACTION_TLIST,
ACTION_TBALANCER
LI_ACTION_TSETTING,
LI_ACTION_TSETTINGPTR,
LI_ACTION_TFUNCTION,
LI_ACTION_TCONDITION,
LI_ACTION_TLIST,
LI_ACTION_TBALANCER
} liActionType;
typedef enum {
BACKEND_OVERLOAD,
BACKEND_DEAD
LI_BACKEND_OVERLOAD,
LI_BACKEND_DEAD
} liBackendError;
/* chunk.h */

56
src/main/actions.c

@ -18,28 +18,28 @@ void li_action_release(liServer *srv, liAction *a) {
assert(g_atomic_int_get(&a->refcount) > 0);
if (g_atomic_int_dec_and_test(&a->refcount)) {
switch (a->type) {
case ACTION_TSETTING:
case LI_ACTION_TSETTING:
break;
case ACTION_TSETTINGPTR:
case LI_ACTION_TSETTINGPTR:
li_release_optionptr(srv, a->data.settingptr.value);
break;
case ACTION_TFUNCTION:
case LI_ACTION_TFUNCTION:
if (a->data.function.free) {
a->data.function.free(srv, a->data.function.param);
}
break;
case ACTION_TCONDITION:
case LI_ACTION_TCONDITION:
li_condition_release(srv, a->data.condition.cond);
li_action_release(srv, a->data.condition.target);
li_action_release(srv, a->data.condition.target_else);
break;
case ACTION_TLIST:
case LI_ACTION_TLIST:
for (i = a->data.list->len; i-- > 0; ) {
li_action_release(srv, g_array_index(a->data.list, liAction*, i));
}
g_array_free(a->data.list, TRUE);
break;
case ACTION_TBALANCER:
case LI_ACTION_TBALANCER:
if (a->data.balancer.free) {
a->data.balancer.free(srv, a->data.balancer.param);
}
@ -58,7 +58,7 @@ liAction *li_action_new_setting(liOptionSet setting) {
liAction *a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TSETTING;
a->type = LI_ACTION_TSETTING;
a->data.setting = setting;
return a;
@ -68,7 +68,7 @@ liAction *li_action_new_settingptr(liOptionPtrSet setting) {
liAction *a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TSETTINGPTR;
a->type = LI_ACTION_TSETTINGPTR;
a->data.settingptr = setting;
return a;
@ -79,7 +79,7 @@ liAction *li_action_new_function(liActionFuncCB func, liActionCleanupCB fcleanup
a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TFUNCTION;
a->type = LI_ACTION_TFUNCTION;
a->data.function.func = func;
a->data.function.cleanup = fcleanup;
a->data.function.free = ffree;
@ -93,7 +93,7 @@ liAction *li_action_new_list() {
a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TLIST;
a->type = LI_ACTION_TLIST;
a->data.list = g_array_new(FALSE, TRUE, sizeof(liAction *));
return a;
@ -104,7 +104,7 @@ liAction *li_action_new_condition(liCondition *cond, liAction *target, liAction
a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TCONDITION;
a->type = LI_ACTION_TCONDITION;
a->data.condition.cond = cond;
a->data.condition.target = target;
a->data.condition.target_else = target_else;
@ -117,7 +117,7 @@ liAction *li_action_new_balancer(liBackendSelectCB bselect, liBackendFallbackCB
a = g_slice_new(liAction);
a->refcount = 1;
a->type = ACTION_TBALANCER;
a->type = LI_ACTION_TBALANCER;
a->data.balancer.select = bselect;
a->data.balancer.fallback = bfallback;
a->data.balancer.finished = bfinished;
@ -134,15 +134,15 @@ static void action_stack_element_release(liServer *srv, liVRequest *vr, action_s
if (!ase || !a) return;
switch (a->type) {
case ACTION_TSETTING:
case ACTION_TSETTINGPTR:
case LI_ACTION_TSETTING:
case LI_ACTION_TSETTINGPTR:
break;
case ACTION_TFUNCTION:
case LI_ACTION_TFUNCTION:
if (ase->data.context && a->data.function.cleanup) {
a->data.function.cleanup(vr, a->data.function.param, ase->data.context);
}
break;
case ACTION_TCONDITION:
case LI_ACTION_TCONDITION:
if (a->data.condition.cond->rvalue.type == LI_COND_VALUE_REGEXP) {
/* pop regex stack */
GArray *rs = vr->action_stack.regex_stack;
@ -156,9 +156,9 @@ static void action_stack_element_release(liServer *srv, liVRequest *vr, action_s
}
}
break;
case ACTION_TLIST:
case LI_ACTION_TLIST:
break;
case ACTION_TBALANCER:
case LI_ACTION_TBALANCER:
a->data.balancer.finished(vr, a->data.balancer.param, ase->data.context);
break;
}
@ -228,7 +228,7 @@ void li_action_enter(liVRequest *vr, liAction *a) {
liActionStack *as = &vr->action_stack;
action_stack_element *top_ase = action_stack_top(as);
action_stack_element ase = { a, { 0 }, FALSE,
(top_ase ? top_ase->backlog_provided || (top_ase->act->type == ACTION_TBALANCER && top_ase->act->data.balancer.provide_backlog) : FALSE) };
(top_ase ? top_ase->backlog_provided || (top_ase->act->type == LI_ACTION_TBALANCER && top_ase->act->data.balancer.provide_backlog) : FALSE) };
li_action_acquire(a);
g_array_append_val(as->stack, ase);
}
@ -240,7 +240,7 @@ static void action_stack_pop(liServer *srv, liVRequest *vr, liActionStack *as) {
ase = &g_array_index(as->stack, action_stack_element, as->stack->len - 1);
if (ase->act->type == ACTION_TBALANCER && !as->backend_finished) {
if (ase->act->type == LI_ACTION_TBALANCER && !as->backend_finished) {
/* release later if backend is finished (i.e. "disconnected") */
g_array_append_val(as->backend_stack, *ase);
} else {
@ -265,7 +265,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
vr->state = LI_VRS_HANDLE_REQUEST_HEADERS;
vr->backend = NULL;
while (NULL != (ase = action_stack_top(as)) && (ase->act->type != ACTION_TBALANCER || !ase->act->data.balancer.provide_backlog)) {
while (NULL != (ase = action_stack_top(as)) && (ase->act->type != LI_ACTION_TBALANCER || !ase->act->data.balancer.provide_backlog)) {
action_stack_pop(srv, vr, as);
}
if (!ase) { /* no backlogging balancer found */
@ -298,7 +298,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
/* a TFUNCTION may enter sub actions _and_ return GO_ON, so we cannot pop the last element
* but we have to remember we already executed it
*/
if (ase->act->type == ACTION_TBALANCER) {
if (ase->act->type == LI_ACTION_TBALANCER) {
/* wait until we found a backend */
VREQUEST_WAIT_FOR_RESPONSE_HEADERS(vr);
}
@ -311,11 +311,11 @@ liHandlerResult li_action_execute(liVRequest *vr) {
ase_ndx = as->stack->len - 1; /* sometimes the stack gets modified - reread "ase" after that */
switch (a->type) {
case ACTION_TSETTING:
case LI_ACTION_TSETTING:
vr->options[a->data.setting.ndx] = a->data.setting.value;
action_stack_pop(srv, vr, as);
break;
case ACTION_TSETTINGPTR:
case LI_ACTION_TSETTINGPTR:
if (vr->optionptrs[a->data.settingptr.ndx] != a->data.settingptr.value) {
g_atomic_int_inc(&a->data.settingptr.value->refcount);
li_release_optionptr(srv, vr->optionptrs[a->data.settingptr.ndx]);
@ -323,7 +323,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
}
action_stack_pop(srv, vr, as);
break;
case ACTION_TFUNCTION:
case LI_ACTION_TFUNCTION:
res = a->data.function.func(vr, a->data.function.param, &ase->data.context);
ase = &g_array_index(as->stack, action_stack_element, ase_ndx);
@ -341,7 +341,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
return res;
}
break;
case ACTION_TCONDITION:
case LI_ACTION_TCONDITION:
condres = FALSE;
res = li_condition_check(vr, a->data.condition.cond, &condres);
switch (res) {
@ -361,7 +361,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
return res;
}
break;
case ACTION_TLIST:
case LI_ACTION_TLIST:
if (ase->data.pos >= a->data.list->len) {
action_stack_pop(srv, vr, as);
} else {
@ -369,7 +369,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
li_action_enter(vr, g_array_index(a->data.list, liAction*, p));
}
break;
case ACTION_TBALANCER:
case LI_ACTION_TBALANCER:
/* skip balancer if request is already handled */
if (li_vrequest_is_handled(vr)) {
ase->finished = TRUE;

4
src/main/config_parser.rl

@ -1088,9 +1088,9 @@
_printf("got condition_chain in line %zd\n", ctx->line);
/* loop over all actions looking for 'and' markers and clear them */
while (cond && cond->type == ACTION_TCONDITION) {
while (cond && cond->type == LI_ACTION_TCONDITION) {
_printf("condition: %p if: %p else: %p\n", (void*)cond, (void*)cond->data.condition.target, (void*)cond->data.condition.target_else);
for (cond_and = cond; cond_and && (cond_and->type == ACTION_TCONDITION) && (uintptr_t)cond_and->data.condition.target & 0x1; cond_and = cond_and->data.condition.target) {
for (cond_and = cond; cond_and && (cond_and->type == LI_ACTION_TCONDITION) && (uintptr_t)cond_and->data.condition.target & 0x1; cond_and = cond_and->data.condition.target) {
cond_and->data.condition.target = (liAction*)((uintptr_t)cond_and->data.condition.target & (~0x1));
_printf("condition_and: %p if: %p else: %p\n", (void*)cond_and, (void*)cond_and->data.condition.target, (void*)cond_and->data.condition.target_else);
}

66
src/main/etag.c

@ -2,9 +2,9 @@
#include <lighttpd/base.h>
#include <lighttpd/plugin_core.h>
tristate_t li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag) {
liTristate li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag) {
GList *l;
tristate_t res = TRI_MAYBE;
liTristate res = LI_TRIMAYBE;
gchar *setag = NULL;
if (!etag) {
@ -19,16 +19,16 @@ tristate_t li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag)
l;
l = li_http_header_find_next(l, CONST_STR_LEN("If-None-Match"))) {
liHttpHeader *h = (liHttpHeader*) l->data;
res = TRI_FALSE; /* if the header was given at least once, we need a match */
res = LI_TRIFALSE; /* if the header was given at least once, we need a match */
if (!setag) return res;
if (strstr(h->data->str + h->keylen + 2, setag)) {
return TRI_TRUE;
return LI_TRITRUE;
}
}
return res;
}
tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified) {
liTristate li_http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified) {
GList *l;
gchar *slm = NULL, *hlm;
liHttpHeader *h;
@ -43,13 +43,13 @@ tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *la
}
l = li_http_header_find_first(vr->request.headers, CONST_STR_LEN("If-Modified-Since"));
if (!l) return TRI_MAYBE; /* no if-modified-since header */
if (!l) return LI_TRIMAYBE; /* no if-modified-since header */
if (li_http_header_find_next(l, CONST_STR_LEN("If-Modified-Since"))) {
return TRI_FALSE; /* we only check one if-modified-since header */
return LI_TRIFALSE; /* we only check one if-modified-since header */
}
h = (liHttpHeader*) l->data;
hlm = h->data->str + h->keylen + 2;
if (!slm) return TRI_FALSE;
if (!slm) return LI_TRIFALSE;
if (NULL == (semicolon = strchr(hlm, ';'))) {
used_len = strlen(hlm);
@ -58,7 +58,7 @@ tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *la
}
if (0 == strncmp(hlm, slm, used_len)) {
return (slm[used_len] == '\0' || slm[used_len] == ';') ? TRI_TRUE : TRI_FALSE;
return (slm[used_len] == '\0' || slm[used_len] == ';') ? LI_TRITRUE : LI_TRIFALSE;
} else {
char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
time_t t_header, t_file;
@ -71,7 +71,7 @@ tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *la
hlm, (int) used_len, (int) sizeof(buf) - 1);
}
/* not returning "412" - should we? */
return TRI_FALSE;
return LI_TRIFALSE;
}
strncpy(buf, hlm, used_len);
@ -80,7 +80,7 @@ tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *la
memset(&tm, 0, sizeof(tm));
if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) {
/* not returning "412" - should we? */
return TRI_FALSE;
return LI_TRIFALSE;
}
tm.tm_isdst = 0;
t_header = mktime(&tm);
@ -90,30 +90,30 @@ tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *la
tm.tm_isdst = 0;
t_file = mktime(&tm);
if (t_file > t_header) return TRI_FALSE;
if (t_file > t_header) return LI_TRIFALSE;
return TRI_TRUE;
return LI_TRITRUE;
}
}
gboolean li_http_response_handle_cachable(liVRequest *vr) {
tristate_t c_able = TRI_MAYBE;
if (c_able != TRI_FALSE) {
liTristate c_able = LI_TRIMAYBE;
if (c_able != LI_TRIFALSE) {
switch (li_http_response_handle_cachable_etag(vr, NULL)) {
case TRI_FALSE: c_able = TRI_FALSE; break;
case TRI_MAYBE: break;
case TRI_TRUE : c_able = TRI_TRUE; break;
case LI_TRIFALSE: c_able = LI_TRIFALSE; break;
case LI_TRIMAYBE: break;
case LI_TRITRUE : c_able = LI_TRITRUE; break;
}
}
if (c_able != TRI_FALSE) {
if (c_able != LI_TRIFALSE) {
switch (li_http_response_handle_cachable_modified(vr, NULL)) {
case TRI_FALSE: c_able = TRI_FALSE; break;
case TRI_MAYBE: break;
case TRI_TRUE : c_able = TRI_TRUE; break;
case LI_TRIFALSE: c_able = LI_TRIFALSE; break;
case LI_TRIMAYBE: break;
case LI_TRITRUE : c_able = LI_TRITRUE; break;
}
}
return c_able == TRI_TRUE;
return c_able == LI_TRITRUE;
}
void li_etag_mutate(GString *mut, GString *etag) {
@ -132,7 +132,7 @@ void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) {
guint flags = CORE_OPTION(LI_CORE_OPTION_ETAG_FLAGS).number;
GString *tmp_str = vr->wrk->tmp_str;
struct tm tm;
tristate_t c_able = cachable ? TRI_MAYBE : TRI_FALSE;
liTristate c_able = cachable ? LI_TRIMAYBE : LI_TRIFALSE;
if (0 == flags) {
li_http_header_remove(vr->response.headers, CONST_STR_LEN("etag"));
@ -157,11 +157,11 @@ void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) {
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("ETag"), GSTR_LEN(tmp_str));
if (c_able != TRI_FALSE) {
if (c_able != LI_TRIFALSE) {
switch (li_http_response_handle_cachable_etag(vr, tmp_str)) {
case TRI_FALSE: c_able = TRI_FALSE; break;
case TRI_MAYBE: break;
case TRI_TRUE : c_able = TRI_TRUE; break;
case LI_TRIFALSE: c_able = LI_TRIFALSE; break;
case LI_TRIMAYBE: break;
case LI_TRITRUE : c_able = LI_TRITRUE; break;
}
}
}
@ -172,14 +172,14 @@ void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable) {
"%a, %d %b %Y %H:%M:%S GMT", &tm));
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Last-Modified"), GSTR_LEN(tmp_str));
if (c_able != TRI_FALSE) {
if (c_able != LI_TRIFALSE) {
switch (li_http_response_handle_cachable_modified(vr, tmp_str)) {
case TRI_FALSE: c_able = TRI_FALSE; break;
case TRI_MAYBE: break;
case TRI_TRUE : c_able = TRI_TRUE; break;
case LI_TRIFALSE: c_able = LI_TRIFALSE; break;
case LI_TRIMAYBE: break;
case LI_TRITRUE : c_able = LI_TRITRUE; break;
}
}
}
if (cachable) *cachable = (c_able == TRI_TRUE);
if (cachable) *cachable = (c_able == LI_TRITRUE);
}

4
src/main/virtualrequest.c

@ -353,10 +353,10 @@ void li_vrequest_backend_error(liVRequest *vr, liBackendError berror) {
}
void li_vrequest_backend_overloaded(liVRequest *vr) {
li_vrequest_backend_error(vr, BACKEND_OVERLOAD);
li_vrequest_backend_error(vr, LI_BACKEND_OVERLOAD);
}
void li_vrequest_backend_dead(liVRequest *vr) {
li_vrequest_backend_error(vr, BACKEND_DEAD);
li_vrequest_backend_error(vr, LI_BACKEND_DEAD);
}

2
src/modules/mod_balancer.c

@ -475,7 +475,7 @@ static liHandlerResult balancer_act_fallback(liVRequest *vr, gboolean backlog_pr
_balancer_context_select_backend(b, context, -1);
if (error == BACKEND_OVERLOAD || be->load > 0) {
if (error == LI_BACKEND_OVERLOAD || be->load > 0) {
/* long timeout for overload - we will enable the backend anyway if another request finishs */
if (be->state == BE_ALIVE) be->wake = ev_now(vr->wrk->loop) + 5.0;

Loading…
Cancel
Save