Skip to content

Commit

Permalink
Merge branch 'master' into limit_upstream_tries
Browse files Browse the repository at this point in the history
  • Loading branch information
supertcy committed Sep 12, 2013
2 parents d7a3e12 + bd5601d commit 9be22ac
Show file tree
Hide file tree
Showing 9 changed files with 767 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/core/nginx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#define NGINX_VER "nginx/" NGINX_VERSION

#define TENGINE "Tengine"
#define tengine_version 1005001
#define TENGINE_VERSION "1.5.1"
#define tengine_version 2000000
#define TENGINE_VERSION "2.0.0"
#define TENGINE_VER TENGINE "/" TENGINE_VERSION

#define NGINX_VAR "NGINX"
Expand Down
68 changes: 68 additions & 0 deletions src/http/modules/ngx_http_rewrite_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,74 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
return NGX_CONF_OK;
}

if (len == 1 && p[0] == '>') {

if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}

code = ngx_http_script_start_code(cf->pool, &lcf->codes,
sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}

*code = ngx_http_script_greater_code;

return NGX_CONF_OK;
}

if (len == 1 && p[0] == '<') {

if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}

code = ngx_http_script_start_code(cf->pool, &lcf->codes,
sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}

*code = ngx_http_script_less_code;

return NGX_CONF_OK;
}

if (len == 2 && p[0] == '>' && p[1] == '=') {

if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}

code = ngx_http_script_start_code(cf->pool, &lcf->codes,
sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}

*code = ngx_http_script_greater_or_equal_code;
return NGX_CONF_OK;

}

if (len == 2 && p[0] == '<' && p[1] == '=') {

if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}

code = ngx_http_script_start_code(cf->pool, &lcf->codes,
sizeof(uintptr_t));
if (code == NULL) {
return NGX_CONF_ERROR;
}

*code = ngx_http_script_less_or_equal_code;
return NGX_CONF_OK;

}

if (len == 2 && p[0] == '!' && p[1] == '=') {

if (ngx_http_rewrite_value(cf, lcf, &value[last]) != NGX_CONF_OK) {
Expand Down
156 changes: 156 additions & 0 deletions src/http/ngx_http_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,162 @@ ngx_http_script_equal_code(ngx_http_script_engine_t *e)
}


void
ngx_http_script_greater_code(ngx_http_script_engine_t *e)
{
ngx_http_variable_value_t *val, *res;
ngx_int_t val_n, res_n;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script greater");

e->sp--;
val = e->sp;
res = e->sp - 1;

e->ip += sizeof(uintptr_t);

val_n = ngx_atoi(val->data, val->len);
if (val_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

res_n = ngx_atoi(res->data, res->len);
if (res_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

if (res_n > val_n) {
*res = ngx_http_variable_true_value;
return;
}

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script greater: no");

*res = ngx_http_variable_null_value;
}


void
ngx_http_script_less_code(ngx_http_script_engine_t *e)
{
ngx_http_variable_value_t *val, *res;
ngx_int_t val_n, res_n;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script less");

e->sp--;
val = e->sp;
res = e->sp - 1;

e->ip += sizeof(uintptr_t);

val_n = ngx_atoi(val->data, val->len);
if (val_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

res_n = ngx_atoi(res->data, res->len);
if (res_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

if (res_n < val_n) {
*res = ngx_http_variable_true_value;
return;
}

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script less: no");

*res = ngx_http_variable_null_value;
}


void
ngx_http_script_greater_or_equal_code(ngx_http_script_engine_t *e)
{
ngx_http_variable_value_t *val, *res;
ngx_int_t val_n, res_n;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script greater or equal");

e->sp--;
val = e->sp;
res = e->sp - 1;

e->ip += sizeof(uintptr_t);

val_n = ngx_atoi(val->data, val->len);
if (val_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

res_n = ngx_atoi(res->data, res->len);
if (res_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

if (res_n >= val_n) {
*res = ngx_http_variable_true_value;
return;
}

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script greater or equal: no");

*res = ngx_http_variable_null_value;
}


void
ngx_http_script_less_or_equal_code(ngx_http_script_engine_t *e)
{
ngx_http_variable_value_t *val, *res;
ngx_int_t val_n, res_n;

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script less or equal");

e->sp--;
val = e->sp;
res = e->sp - 1;

e->ip += sizeof(uintptr_t);

val_n = ngx_atoi(val->data, val->len);
if (val_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

res_n = ngx_atoi(res->data, res->len);
if (res_n == NGX_ERROR) {
*res = ngx_http_variable_null_value;
return;
}

if (res_n <= val_n) {
*res = ngx_http_variable_true_value;
return;
}

ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
"http script less or equal: no");

*res = ngx_http_variable_null_value;
}


void
ngx_http_script_not_equal_code(ngx_http_script_engine_t *e)
{
Expand Down
4 changes: 4 additions & 0 deletions src/http/ngx_http_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ void ngx_http_script_return_code(ngx_http_script_engine_t *e);
void ngx_http_script_break_code(ngx_http_script_engine_t *e);
void ngx_http_script_if_code(ngx_http_script_engine_t *e);
void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
void ngx_http_script_greater_code(ngx_http_script_engine_t *e);
void ngx_http_script_less_code(ngx_http_script_engine_t *e);
void ngx_http_script_greater_or_equal_code(ngx_http_script_engine_t *e);
void ngx_http_script_less_or_equal_code(ngx_http_script_engine_t *e);
void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
void ngx_http_script_file_code(ngx_http_script_engine_t *e);
void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
Expand Down
Loading

0 comments on commit 9be22ac

Please sign in to comment.