Skip to content

Commit

Permalink
more coding style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
agentzh committed Sep 2, 2013
1 parent cea7499 commit 845ff07
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions src/ngx_http_memc_handler.c
Expand Up @@ -12,10 +12,11 @@




static ngx_int_t ngx_http_memc_flags_as_http_time_variable( static ngx_int_t ngx_http_memc_flags_as_http_time_variable(
ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data);




static ngx_http_variable_t ngx_http_memc_variables[] = { static ngx_http_variable_t ngx_http_memc_variables[] = {

{ ngx_string("memc_flags_as_http_time"), NULL, { ngx_string("memc_flags_as_http_time"), NULL,
ngx_http_memc_flags_as_http_time_variable, 0, ngx_http_memc_flags_as_http_time_variable, 0,
0, 0 }, 0, 0 },
Expand Down Expand Up @@ -115,20 +116,19 @@ ngx_http_memc_handler(ngx_http_request_t *r)


} else { } else {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"ngx_memc: $memc_cmd variable requires explicit " "ngx_memc: $memc_cmd variable requires explicit "
"assignment for HTTP request method %V", "assignment for HTTP request method %V",
&r->method_name); &r->method_name);


return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }
} else { } else {
memc_cmd = ngx_http_memc_parse_cmd(cmd_vv->data, cmd_vv->len, memc_cmd = ngx_http_memc_parse_cmd(cmd_vv->data, cmd_vv->len,
&is_storage_cmd); &is_storage_cmd);


if (memc_cmd == ngx_http_memc_cmd_unknown) { if (memc_cmd == ngx_http_memc_cmd_unknown) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"ngx_memc: unknown $memc_cmd \"%v\"", cmd_vv); "ngx_memc: unknown $memc_cmd \"%v\"", cmd_vv);

return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }
} }
Expand All @@ -137,10 +137,10 @@ ngx_http_memc_handler(ngx_http_request_t *r)


dd("XXX connect timeout %d", (int) mlcf->upstream.connect_timeout); dd("XXX connect timeout %d", (int) mlcf->upstream.connect_timeout);


if ( ! ngx_http_memc_in_cmds_allowed(mlcf, memc_cmd) ) { if (!ngx_http_memc_in_cmds_allowed(mlcf, memc_cmd)) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"ngx_memc: User requests to run memcached command " "ngx_memc: User requests to run memcached command "
"\"%v\"", cmd_vv); "\"%v\"", cmd_vv);


return NGX_HTTP_FORBIDDEN; return NGX_HTTP_FORBIDDEN;
} }
Expand Down Expand Up @@ -179,15 +179,15 @@ ngx_http_memc_handler(ngx_http_request_t *r)
if (mlcf->complex_target) { if (mlcf->complex_target) {
/* variables used in the memc_pass directive */ /* variables used in the memc_pass directive */
if (ngx_http_complex_value(r, mlcf->complex_target, &target) if (ngx_http_complex_value(r, mlcf->complex_target, &target)
!= NGX_OK) != NGX_OK)
{ {
dd("failed to compile"); dd("failed to compile");
return NGX_ERROR; return NGX_ERROR;
} }


if (target.len == 0) { if (target.len == 0) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"memc: handler: empty \"memc_pass\" target"); "memc: handler: empty \"memc_pass\" target");
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }


Expand All @@ -199,8 +199,7 @@ ngx_http_memc_handler(ngx_http_request_t *r)


if (mlcf->upstream.upstream == NULL) { if (mlcf->upstream.upstream == NULL) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"memc: upstream \"%V\" not found", &target); "memc: upstream \"%V\" not found", &target);

return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
} }
Expand Down Expand Up @@ -300,18 +299,18 @@ ngx_http_memc_handler(ngx_http_request_t *r)
|| memc_cmd == ngx_http_memc_cmd_delete) || memc_cmd == ngx_http_memc_cmd_delete)
{ {
exptime_vv = ngx_http_get_indexed_variable(r, exptime_vv = ngx_http_get_indexed_variable(r,
ngx_http_memc_exptime_index); ngx_http_memc_exptime_index);


if (exptime_vv == NULL) { if (exptime_vv == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }


ctx->memc_exptime_vv = exptime_vv; ctx->memc_exptime_vv = exptime_vv;


if ( ! exptime_vv->not_found if (!exptime_vv->not_found
&& exptime_vv->len && exptime_vv->len
&& ! ngx_http_memc_valid_uint32_str( && !ngx_http_memc_valid_uint32_str(exptime_vv->data,
exptime_vv->data, exptime_vv->len)) exptime_vv->len))
{ {
return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }
Expand All @@ -326,38 +325,38 @@ ngx_http_memc_handler(ngx_http_request_t *r)


ctx->memc_flags_vv = flags_vv; ctx->memc_flags_vv = flags_vv;


if ( is_storage_cmd if (is_storage_cmd
&& ! flags_vv->not_found && !flags_vv->not_found
&& flags_vv->len && flags_vv->len
&& ! ngx_http_memc_valid_uint32_str( && !ngx_http_memc_valid_uint32_str(flags_vv->data, flags_vv->len))
flags_vv->data, flags_vv->len))
{ {
return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }
} }


if (is_storage_cmd || memc_cmd == ngx_http_memc_cmd_incr if (is_storage_cmd
|| memc_cmd == ngx_http_memc_cmd_decr) || memc_cmd == ngx_http_memc_cmd_incr
|| memc_cmd == ngx_http_memc_cmd_decr)
{ {
value_vv = ngx_http_get_indexed_variable(r, value_vv = ngx_http_get_indexed_variable(r,
ngx_http_memc_value_index); ngx_http_memc_value_index);
if (value_vv == NULL) { if (value_vv == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }


if (memc_cmd == ngx_http_memc_cmd_incr if (memc_cmd == ngx_http_memc_cmd_incr
|| memc_cmd == ngx_http_memc_cmd_decr) || memc_cmd == ngx_http_memc_cmd_decr)
{ {
if (value_vv->not_found || value_vv->len == 0) { if (value_vv->not_found || value_vv->len == 0) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"The \"$memc_value\" variable is required for " "the \"$memc_value\" variable is required for "
"command \"%V\"", &ctx->cmd_str); "command \"%V\"", &ctx->cmd_str);


return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }


if (!ngx_http_memc_valid_uint64_str( if (!ngx_http_memc_valid_uint64_str(value_vv->data,
value_vv->data, value_vv->len)) value_vv->len))
{ {
return NGX_HTTP_BAD_REQUEST; return NGX_HTTP_BAD_REQUEST;
} }
Expand Down Expand Up @@ -471,26 +470,27 @@ ngx_http_memc_init(ngx_conf_t *cf)
return NGX_OK; return NGX_OK;
} }


if ((ngx_http_memc_key_index = ngx_http_memc_add_variable( ngx_http_memc_key_index = ngx_http_memc_add_variable(cf,
cf, &ngx_http_memc_key)) == NGX_ERROR) &ngx_http_memc_key);
{ if (ngx_http_memc_key_index == NGX_ERROR) {
return NGX_ERROR; return NGX_ERROR;
} }


if ((ngx_http_memc_cmd_index = ngx_http_memc_add_variable( ngx_http_memc_cmd_index = ngx_http_memc_add_variable(cf,
cf, &ngx_http_memc_cmd)) == NGX_ERROR) &ngx_http_memc_cmd);
{ if (ngx_http_memc_cmd_index == NGX_ERROR) {
return NGX_ERROR; return NGX_ERROR;
} }


if ((ngx_http_memc_flags_index = ngx_http_memc_add_variable( ngx_http_memc_flags_index = ngx_http_memc_add_variable(cf,
cf, &ngx_http_memc_flags)) == NGX_ERROR) &ngx_http_memc_flags);
{ if (ngx_http_memc_flags_index == NGX_ERROR) {
return NGX_ERROR; return NGX_ERROR;
} }


if ((ngx_http_memc_exptime_index = ngx_http_memc_add_variable( ngx_http_memc_exptime_index = ngx_http_memc_add_variable(cf,
cf, &ngx_http_memc_exptime)) == NGX_ERROR) &ngx_http_memc_exptime);
if (ngx_http_memc_exptime_index == NGX_ERROR)
{ {
return NGX_ERROR; return NGX_ERROR;
} }
Expand Down

0 comments on commit 845ff07

Please sign in to comment.