Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

various file name and coding style fixes.

  • Loading branch information...
commit 46ffbe856fcf4ed0bbdfde725ce6cc0bbce24ccd 1 parent d42b703
@agentzh agentzh authored
Showing with 266 additions and 177 deletions.
  1. +2 −2 config
  2. +32 −5 src/ddebug.h
  3. +17 −9 src/{echo.c → ngx_http_echo_echo.c}
  4. 0  src/{echo.h → ngx_http_echo_echo.h}
  5. +15 −11 src/{filter.c → ngx_http_echo_filter.c}
  6. 0  src/{filter.h → ngx_http_echo_filter.h}
  7. +8 −6 src/{foreach.c → ngx_http_echo_foreach.c}
  8. 0  src/{foreach.h → ngx_http_echo_foreach.h}
  9. +15 −14 src/{handler.c → ngx_http_echo_handler.c}
  10. 0  src/{handler.h → ngx_http_echo_handler.h}
  11. +11 −6 src/{location.c → ngx_http_echo_location.c}
  12. 0  src/{location.h → ngx_http_echo_location.h}
  13. +114 −72 src/{main.c → ngx_http_echo_module.c}
  14. +8 −8 src/{request_info.c → ngx_http_echo_request_info.c}
  15. 0  src/{request_info.h → ngx_http_echo_request_info.h}
  16. +17 −17 src/{sleep.c → ngx_http_echo_sleep.c}
  17. 0  src/{sleep.h → ngx_http_echo_sleep.h}
  18. +13 −13 src/{subrequest.c → ngx_http_echo_subrequest.c}
  19. 0  src/{subrequest.h → ngx_http_echo_subrequest.h}
  20. +4 −4 src/{timer.c → ngx_http_echo_timer.c}
  21. 0  src/{timer.h → ngx_http_echo_timer.h}
  22. +5 −5 src/{util.c → ngx_http_echo_util.c}
  23. 0  src/{util.h → ngx_http_echo_util.h}
  24. +5 −5 src/{var.c → ngx_http_echo_var.c}
  25. 0  src/{var.h → ngx_http_echo_var.h}
View
4 config
@@ -1,5 +1,5 @@
ngx_addon_name=ngx_http_echo_module
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_echo_module"
-NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/main.c $ngx_addon_dir/src/util.c $ngx_addon_dir/src/timer.c $ngx_addon_dir/src/var.c $ngx_addon_dir/src/handler.c $ngx_addon_dir/src/filter.c $ngx_addon_dir/src/sleep.c $ngx_addon_dir/src/location.c $ngx_addon_dir/src/echo.c $ngx_addon_dir/src/request_info.c $ngx_addon_dir/src/subrequest.c $ngx_addon_dir/src/foreach.c"
-NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ngx_http_echo_module.h $ngx_addon_dir/src/ddebug.h $ngx_addon_dir/src/handler.h $ngx_addon_dir/src/util.h $ngx_addon_dir/src/sleep.h $ngx_addon_dir/src/filter.h $ngx_addon_dir/src/var.h $ngx_addon_dir/src/location.h $ngx_addon_dir/src/echo.h $ngx_addon_dir/src/request_info.h $ngx_addon_dir/src/subrequest.h $ngx_addon_dir/src/foreach.h"
+NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_echo_module.c $ngx_addon_dir/src/ngx_http_echo_util.c $ngx_addon_dir/src/ngx_http_echo_timer.c $ngx_addon_dir/src/ngx_http_echo_var.c $ngx_addon_dir/src/ngx_http_echo_handler.c $ngx_addon_dir/src/ngx_http_echo_filter.c $ngx_addon_dir/src/ngx_http_echo_sleep.c $ngx_addon_dir/src/ngx_http_echo_location.c $ngx_addon_dir/src/ngx_http_echo_echo.c $ngx_addon_dir/src/ngx_http_echo_request_info.c $ngx_addon_dir/src/ngx_http_echo_subrequest.c $ngx_addon_dir/src/ngx_http_echo_foreach.c"
+NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ngx_http_echo_module.h $ngx_addon_dir/src/ddebug.h $ngx_addon_dir/src/ngx_http_echo_handler.h $ngx_addon_dir/src/ngx_http_echo_util.h $ngx_addon_dir/src/ngx_http_echo_sleep.h $ngx_addon_dir/src/ngx_http_echo_filter.h $ngx_addon_dir/src/ngx_http_echo_var.h $ngx_addon_dir/src/ngx_http_echo_location.h $ngx_addon_dir/src/ngx_http_echo_echo.h $ngx_addon_dir/src/ngx_http_echo_request_info.h $ngx_addon_dir/src/ngx_http_echo_subrequest.h $ngx_addon_dir/src/ngx_http_echo_foreach.h"
View
37 src/ddebug.h
@@ -3,11 +3,11 @@
#include <ngx_core.h>
-#if (DDEBUG)
+#if defined(DDEBUG) && (DDEBUG)
# if (NGX_HAVE_VARIADIC_MACROS)
-# define DD(...) fprintf(stderr, "*** "); \
+# define dd(...) fprintf(stderr, "echo *** "); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, " at %s line %d.\n", __FILE__, __LINE__)
@@ -18,7 +18,7 @@
#include <stdarg.h>
-static void DD(const char* fmt, ...) {
+static void dd(const char * fmt, ...) {
}
# endif
@@ -27,18 +27,45 @@ static void DD(const char* fmt, ...) {
# if (NGX_HAVE_VARIADIC_MACROS)
-# define DD(...)
+# define dd(...)
# else
#include <stdarg.h>
-static void DD(const char* fmt, ...) {
+static void dd(const char * fmt, ...) {
}
# endif
#endif
+#if defined(DDEBUG) && (DDEBUG)
+
+#define dd_check_read_event_handler(r) \
+ dd("r->read_event_handler = %s", \
+ r->read_event_handler == ngx_http_block_reading ? \
+ "ngx_http_block_reading" : \
+ r->read_event_handler == ngx_http_test_reading ? \
+ "ngx_http_test_reading" : \
+ r->read_event_handler == ngx_http_request_empty_handler ? \
+ "ngx_http_request_empty_handler" : "UNKNOWN")
+
+#define dd_check_write_event_handler(r) \
+ dd("r->write_event_handler = %s", \
+ r->write_event_handler == ngx_http_handler ? \
+ "ngx_http_handler" : \
+ r->write_event_handler == ngx_http_core_run_phases ? \
+ "ngx_http_core_run_phases" : \
+ r->write_event_handler == ngx_http_request_empty_handler ? \
+ "ngx_http_request_empty_handler" : "UNKNOWN")
+
+#else
+
+#define dd_check_read_event_handler(r)
+#define dd_check_write_event_handler(r)
+
+#endif
+
#endif /* DDEBUG_H */
View
26 src/echo.c → src/ngx_http_echo_echo.c
@@ -1,8 +1,8 @@
#define DDEBUG 0
#include "ddebug.h"
-#include "echo.h"
-#include "util.h"
+#include "ngx_http_echo_echo.h"
+#include "ngx_http_echo_util.h"
#include <nginx.h>
@@ -11,11 +11,12 @@ static ngx_buf_t ngx_http_echo_space_buf;
static ngx_buf_t ngx_http_echo_newline_buf;
ngx_int_t
-ngx_http_echo_echo_init(ngx_conf_t *cf) {
+ngx_http_echo_echo_init(ngx_conf_t *cf)
+{
static u_char space_str[] = " ";
static u_char newline_str[] = "\n";
- DD("global init...");
+ dd("global init...");
ngx_memzero(&ngx_http_echo_space_buf, sizeof(ngx_buf_t));
ngx_http_echo_space_buf.memory = 1;
@@ -38,9 +39,11 @@ ngx_http_echo_echo_init(ngx_conf_t *cf) {
return NGX_OK;
}
+
ngx_int_t
ngx_http_echo_exec_echo(ngx_http_request_t *r,
- ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args) {
+ ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args)
+{
ngx_uint_t i;
ngx_buf_t *space_buf;
@@ -53,7 +56,7 @@ ngx_http_echo_exec_echo(ngx_http_request_t *r,
ngx_chain_t *cl = NULL; /* the head of the chain link */
ngx_chain_t **ll = &cl; /* always point to the address of the last link */
- DD("now exec echo...");
+ dd("now exec echo...");
if (computed_args == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -152,13 +155,17 @@ ngx_http_echo_exec_echo(ngx_http_request_t *r,
return ngx_http_echo_send_chain_link(r, ctx, cl);
}
+
ngx_int_t
-ngx_http_echo_exec_echo_flush(ngx_http_request_t *r, ngx_http_echo_ctx_t *ctx) {
+ngx_http_echo_exec_echo_flush(ngx_http_request_t *r, ngx_http_echo_ctx_t *ctx)
+{
return ngx_http_send_special(r, NGX_HTTP_FLUSH);
}
+
ngx_int_t
-ngx_http_echo_exec_echo_request_body(ngx_http_request_t *r, ngx_http_echo_ctx_t *ctx) {
+ngx_http_echo_exec_echo_request_body(ngx_http_request_t *r, ngx_http_echo_ctx_t *ctx)
+{
if (r->request_body && r->request_body->bufs) {
return ngx_http_echo_send_chain_link(r, ctx, r->request_body->bufs);
}
@@ -168,7 +175,8 @@ ngx_http_echo_exec_echo_request_body(ngx_http_request_t *r, ngx_http_echo_ctx_t
ngx_int_t
ngx_http_echo_exec_echo_duplicate(ngx_http_request_t *r,
- ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args) {
+ ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args)
+{
ngx_str_t *computed_arg;
ngx_str_t *computed_arg_elts;
ssize_t i, count;
View
0  src/echo.h → src/ngx_http_echo_echo.h
File renamed without changes
View
26 src/filter.c → src/ngx_http_echo_filter.c
@@ -1,9 +1,9 @@
#define DDEBUG 0
#include "ddebug.h"
-#include "filter.h"
-#include "util.h"
-#include "echo.h"
+#include "ngx_http_echo_filter.h"
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_echo.h"
#include <ngx_log.h>
@@ -21,14 +21,15 @@ static ngx_int_t ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *i
static ngx_int_t ngx_http_echo_exec_filter_cmds(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx, ngx_array_t *cmds, ngx_uint_t *iterator);
+
ngx_int_t
ngx_http_echo_filter_init (ngx_conf_t *cf) {
if (ngx_http_echo_filter_used) {
- DD("top header filter: %ld", (unsigned long) ngx_http_top_header_filter);
+ dd("top header filter: %ld", (unsigned long) ngx_http_top_header_filter);
ngx_http_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_echo_header_filter;
- DD("top body filter: %ld", (unsigned long) ngx_http_top_body_filter);
+ dd("top body filter: %ld", (unsigned long) ngx_http_top_body_filter);
ngx_http_next_body_filter = ngx_http_top_body_filter;
ngx_http_top_body_filter = ngx_http_echo_body_filter;
}
@@ -36,13 +37,14 @@ ngx_http_echo_filter_init (ngx_conf_t *cf) {
return NGX_OK;
}
+
static ngx_int_t
ngx_http_echo_header_filter(ngx_http_request_t *r) {
ngx_http_echo_loc_conf_t *conf;
ngx_http_echo_ctx_t *ctx;
ngx_int_t rc;
- DD("We're in the header filter...");
+ dd("We're in the header filter...");
ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module);
@@ -81,6 +83,7 @@ ngx_http_echo_header_filter(ngx_http_request_t *r) {
return ngx_http_next_header_filter(r);
}
+
static ngx_int_t
ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in) {
ngx_http_echo_ctx_t *ctx;
@@ -126,7 +129,7 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in) {
cl->buf->sync = 1;
last = 1;
} else if (r != r->main && cl->buf->sync) {
- DD("Found sync buf");
+ dd("Found sync buf");
last = 1;
}
}
@@ -137,20 +140,21 @@ ngx_http_echo_body_filter(ngx_http_request_t *r, ngx_chain_t *in) {
return rc;
}
- DD("exec filter cmds for after body cmds");
+ dd("exec filter cmds for after body cmds");
rc = ngx_http_echo_exec_filter_cmds(r, ctx, conf->after_body_cmds, &ctx->next_after_body_cmd);
if (rc != NGX_OK) {
- DD("FAILED: exec filter cmds for after body cmds");
+ dd("FAILED: exec filter cmds for after body cmds");
return NGX_ERROR;
}
ctx->skip_filter = 1;
- DD("after body cmds executed...terminating...");
+ dd("after body cmds executed...terminating...");
return ngx_http_send_special(r, NGX_HTTP_LAST);
}
+
static ngx_int_t
ngx_http_echo_exec_filter_cmds(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx, ngx_array_t *cmds,
@@ -184,7 +188,7 @@ ngx_http_echo_exec_filter_cmds(ngx_http_request_t *r,
switch (cmd->opcode) {
case echo_opcode_echo_before_body:
case echo_opcode_echo_after_body:
- DD("exec echo_before_body or echo_after_body...");
+ dd("exec echo_before_body or echo_after_body...");
rc = ngx_http_echo_exec_echo(r, ctx, computed_args);
if (rc != NGX_OK) {
return rc;
View
0  src/filter.h → src/ngx_http_echo_filter.h
File renamed without changes
View
14 src/foreach.c → src/ngx_http_echo_foreach.c
@@ -1,8 +1,8 @@
#define DDEBUG 0
#include "ddebug.h"
-#include "foreach.h"
-#include "util.h"
+#include "ngx_http_echo_foreach.h"
+#include "ngx_http_echo_util.h"
#include <nginx.h>
@@ -38,6 +38,7 @@ ngx_http_echo_it_variable(ngx_http_request_t *r,
return NGX_OK;
}
+
ngx_int_t
ngx_http_echo_exec_echo_foreach_split(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args) {
@@ -60,7 +61,7 @@ ngx_http_echo_exec_echo_foreach_split(ngx_http_request_t *r,
compound = &computed_arg_elts[1];
- DD("HEY coumpound len: %u", compound->len);
+ dd("HEY coumpound len: %u", compound->len);
ctx->foreach = ngx_palloc(r->pool, sizeof(ngx_http_echo_foreach_ctx_t));
if (ctx->foreach == NULL) {
@@ -82,10 +83,10 @@ ngx_http_echo_exec_echo_foreach_split(ngx_http_request_t *r,
end = compound->data + compound->len;
while ((last = ngx_http_echo_strlstrn(pos, end, delimiter->data, delimiter->len - 1))
!= NULL) {
- DD("entered the loop");
+ dd("entered the loop");
if (last == pos) {
- DD("!!! len == 0");
+ dd("!!! len == 0");
pos = last + delimiter->len;
continue;
}
@@ -128,6 +129,7 @@ ngx_http_echo_exec_echo_foreach_split(ngx_http_request_t *r,
return NGX_OK;
}
+
ngx_int_t
ngx_http_echo_exec_echo_end(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx) {
@@ -148,7 +150,7 @@ ngx_http_echo_exec_echo_end(ngx_http_request_t *r,
return NGX_OK;
}
- DD("echo_end: ++ next_choice (total: %u): %u", ctx->foreach->choices->nelts, ctx->foreach->next_choice);
+ dd("echo_end: ++ next_choice (total: %u): %u", ctx->foreach->choices->nelts, ctx->foreach->next_choice);
/* the main handler dispatcher loop will increment
* ctx->next_handler_cmd for us anyway. */
View
0  src/foreach.h → src/ngx_http_echo_foreach.h
File renamed without changes
View
29 src/handler.c → src/ngx_http_echo_handler.c
@@ -2,16 +2,16 @@
#include "ddebug.h"
-#include "handler.h"
-#include "echo.h"
-#include "util.h"
-#include "sleep.h"
-#include "var.h"
-#include "timer.h"
-#include "location.h"
-#include "subrequest.h"
-#include "request_info.h"
-#include "foreach.h"
+#include "ngx_http_echo_handler.h"
+#include "ngx_http_echo_echo.h"
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_sleep.h"
+#include "ngx_http_echo_var.h"
+#include "ngx_http_echo_timer.h"
+#include "ngx_http_echo_location.h"
+#include "ngx_http_echo_subrequest.h"
+#include "ngx_http_echo_request_info.h"
+#include "ngx_http_echo_foreach.h"
#include <nginx.h>
#include <ngx_log.h>
@@ -28,6 +28,7 @@ ngx_http_echo_handler_init(ngx_conf_t *cf) {
return ngx_http_echo_add_variables(cf);
}
+
ngx_int_t
ngx_http_echo_handler(ngx_http_request_t *r) {
ngx_http_echo_loc_conf_t *elcf;
@@ -54,7 +55,7 @@ ngx_http_echo_handler(ngx_http_request_t *r) {
ngx_http_set_ctx(r, ctx, ngx_http_echo_module);
}
- DD("exec handler: %s: %u", r->uri.data, ctx->next_handler_cmd);
+ dd("exec handler: %s: %u", r->uri.data, ctx->next_handler_cmd);
cmd_elts = cmds->elts;
for (; ctx->next_handler_cmd < cmds->nelts; ctx->next_handler_cmd++) {
@@ -81,7 +82,7 @@ ngx_http_echo_handler(ngx_http_request_t *r) {
case echo_opcode_echo:
/* XXX moved the following code to a separate
* function */
- DD("found echo opcode");
+ dd("found echo opcode");
rc = ngx_http_echo_exec_echo(r, ctx, computed_args);
if (rc != NGX_OK) {
return rc;
@@ -96,7 +97,7 @@ ngx_http_echo_handler(ngx_http_request_t *r) {
break;
case echo_opcode_echo_location_async:
- DD("found opcode echo location async...");
+ dd("found opcode echo location async...");
rc = ngx_http_echo_exec_echo_location_async(r, ctx,
computed_args);
if (rc != NGX_OK) {
@@ -117,7 +118,7 @@ ngx_http_echo_handler(ngx_http_request_t *r) {
break;
case echo_opcode_echo_subrequest_async:
- DD("found opcode echo subrequest async...");
+ dd("found opcode echo subrequest async...");
rc = ngx_http_echo_exec_echo_subrequest_async(r, ctx,
computed_args);
if (rc != NGX_OK) {
View
0  src/handler.h → src/ngx_http_echo_handler.h
File renamed without changes
View
17 src/location.c → src/ngx_http_echo_location.c
@@ -1,9 +1,10 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "util.h"
-#include "location.h"
-#include "handler.h"
+
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_location.h"
+#include "ngx_http_echo_handler.h"
+
#include <nginx.h>
static ngx_int_t ngx_http_echo_adjust_subrequest(ngx_http_request_t *sr);
@@ -11,6 +12,7 @@ static ngx_int_t ngx_http_echo_adjust_subrequest(ngx_http_request_t *sr);
static ngx_int_t ngx_http_echo_post_subrequest(ngx_http_request_t *r,
void *data, ngx_int_t rc);
+
ngx_int_t
ngx_http_echo_exec_echo_location_async(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args) {
@@ -36,8 +38,8 @@ ngx_http_echo_exec_echo_location_async(ngx_http_request_t *r,
url_args = NULL;
}
- DD("location: %s", location.data);
- DD("location args: %s", (char*) (url_args ? url_args->data : (u_char*)"NULL"));
+ dd("location: %s", location.data);
+ dd("location args: %s", (char*) (url_args ? url_args->data : (u_char*)"NULL"));
args.data = NULL;
args.len = 0;
@@ -68,6 +70,7 @@ ngx_http_echo_exec_echo_location_async(ngx_http_request_t *r,
return NGX_OK;
}
+
ngx_int_t
ngx_http_echo_exec_echo_location(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx, ngx_array_t *computed_args) {
@@ -131,6 +134,7 @@ ngx_http_echo_exec_echo_location(ngx_http_request_t *r,
return NGX_OK;
}
+
static ngx_int_t
ngx_http_echo_post_subrequest(ngx_http_request_t *r,
void *data, ngx_int_t rc) {
@@ -148,6 +152,7 @@ ngx_http_echo_post_subrequest(ngx_http_request_t *r,
return rc;
}
+
static ngx_int_t
ngx_http_echo_adjust_subrequest(ngx_http_request_t *sr) {
ngx_http_core_main_conf_t *cmcf;
View
0  src/location.h → src/ngx_http_echo_location.h
File renamed without changes
View
186 src/main.c → src/ngx_http_echo_module.c
@@ -1,74 +1,75 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "handler.h"
-#include "filter.h"
-#include "request_info.h"
+
+#include "ngx_http_echo_handler.h"
+#include "ngx_http_echo_filter.h"
+#include "ngx_http_echo_request_info.h"
#include <nginx.h>
#include <ngx_config.h>
#include <ngx_log.h>
/* config init handler */
-static void* ngx_http_echo_create_conf(ngx_conf_t *cf);
+static void * ngx_http_echo_create_conf(ngx_conf_t *cf);
/* config directive handlers */
-static char* ngx_http_echo_echo(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static char * ngx_http_echo_echo(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_request_body(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_request_body(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_sleep(ngx_conf_t *cf, ngx_command_t *cmd,
+static char * ngx_http_echo_echo_sleep(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
-static char* ngx_http_echo_echo_flush(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static char * ngx_http_echo_echo_flush(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_blocking_sleep(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_blocking_sleep(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_reset_timer(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_reset_timer(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_before_body(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_before_body(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_after_body(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_after_body(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_location_async(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_location_async(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_location(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_location(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_subrequest_async(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_subrequest_async(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_subrequest(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_subrequest(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_duplicate(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_duplicate(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_read_request_body(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_read_request_body(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_foreach_split(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_foreach_split(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_end(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_end(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_echo_abort_parent(ngx_conf_t *cf, ngx_command_t *cmd,
+static char * ngx_http_echo_echo_abort_parent(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
-static char* ngx_http_echo_echo_exec(ngx_conf_t *cf,
+static char * ngx_http_echo_echo_exec(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
-static char* ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
+static char * ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
ngx_http_echo_cmd_category_t cat,
ngx_conf_t *cf, ngx_command_t *cmd, void* conf);
+
static ngx_http_module_t ngx_http_echo_module_ctx = {
/* TODO we could add our own variables here... */
ngx_http_echo_handler_init, /* preconfiguration */
@@ -84,6 +85,7 @@ static ngx_http_module_t ngx_http_echo_module_ctx = {
NULL /* merge location configuration */
};
+
static ngx_command_t ngx_http_echo_commands[] = {
{ ngx_string("echo"),
@@ -215,6 +217,7 @@ static ngx_command_t ngx_http_echo_commands[] = {
ngx_null_command
};
+
ngx_module_t ngx_http_echo_module = {
NGX_MODULE_V1,
&ngx_http_echo_module_ctx, /* module context */
@@ -230,20 +233,25 @@ ngx_module_t ngx_http_echo_module = {
NGX_MODULE_V1_PADDING
};
-static void*
-ngx_http_echo_create_conf(ngx_conf_t *cf) {
+
+static void *
+ngx_http_echo_create_conf(ngx_conf_t *cf)
+{
ngx_http_echo_loc_conf_t *conf;
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_echo_loc_conf_t));
if (conf == NULL) {
return NGX_CONF_ERROR;
}
+
return conf;
}
-static char*
+
+static char *
ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
ngx_http_echo_cmd_category_t cat,
- ngx_conf_t *cf, ngx_command_t *cmd, void* conf) {
+ ngx_conf_t *cf, ngx_command_t *cmd, void* conf)
+{
ngx_http_core_loc_conf_t *clcf;
/* ngx_http_echo_loc_conf_t *ulcf = conf; */
ngx_array_t **args_ptr;
@@ -265,17 +273,17 @@ ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
return NGX_CONF_ERROR;
}
if (cat == echo_handler_cmd) {
- DD("registering the content handler");
+ dd("registering the content handler");
/* register the content handler */
clcf = ngx_http_conf_get_module_loc_conf(cf,
ngx_http_core_module);
if (clcf == NULL) {
return NGX_CONF_ERROR;
}
- DD("registering the content handler (2)");
+ dd("registering the content handler (2)");
clcf->handler = ngx_http_echo_handler;
} else {
- DD("filter used = 1");
+ dd("filter used = 1");
ngx_http_echo_filter_used = 1;
}
}
@@ -298,7 +306,7 @@ ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
return NGX_CONF_ERROR;
}
arg->raw_value = raw_args[i];
- DD("found raw arg %s", raw_args[i].data);
+ dd("found raw arg %s", raw_args[i].data);
arg->lengths = NULL;
arg->values = NULL;
n = ngx_http_script_variables_count(&arg->raw_value);
@@ -319,75 +327,93 @@ ngx_http_echo_helper(ngx_http_echo_opcode_t opcode,
return NGX_CONF_OK;
}
-static char*
-ngx_http_echo_echo(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
- DD("in echo_echo...");
+
+static char *
+ngx_http_echo_echo(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ dd("in echo_echo...");
return ngx_http_echo_helper(echo_opcode_echo,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_request_body(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
- DD("in echo_echo_request_body...");
+ ngx_command_t *cmd, void *conf)
+{
+ dd("in echo_echo_request_body...");
return ngx_http_echo_helper(echo_opcode_echo_request_body,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
-ngx_http_echo_echo_sleep(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
- DD("in echo_sleep...");
+
+static char *
+ngx_http_echo_echo_sleep(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ dd("in echo_sleep...");
return ngx_http_echo_helper(echo_opcode_echo_sleep,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
-ngx_http_echo_echo_flush(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
- DD("in echo_flush...");
+
+static char *
+ngx_http_echo_echo_flush(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ dd("in echo_flush...");
return ngx_http_echo_helper(echo_opcode_echo_flush,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
-ngx_http_echo_echo_blocking_sleep(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
- DD("in echo_blocking_sleep...");
+
+static char *
+ngx_http_echo_echo_blocking_sleep(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ dd("in echo_blocking_sleep...");
return ngx_http_echo_helper(echo_opcode_echo_blocking_sleep,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_reset_timer(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
+ ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(echo_opcode_echo_reset_timer,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_before_body(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
- DD("processing echo_before_body directive...");
+ ngx_command_t *cmd, void *conf)
+{
+ dd("processing echo_before_body directive...");
return ngx_http_echo_helper(echo_opcode_echo_before_body,
echo_filter_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_after_body(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
+ ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(echo_opcode_echo_after_body,
echo_filter_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_location_async(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf) {
+ void *conf)
+{
#if ! defined(nginx_version)
@@ -407,9 +433,11 @@ static char*
}
-static char*
+
+static char *
ngx_http_echo_echo_location(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf) {
+ void *conf)
+{
#if ! defined(nginx_version)
@@ -429,9 +457,11 @@ static char*
}
-static char*
+
+static char *
ngx_http_echo_echo_subrequest_async(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf) {
+ void *conf)
+{
#if ! defined(nginx_version)
@@ -451,9 +481,11 @@ static char*
}
-static char*
+
+static char *
ngx_http_echo_echo_subrequest(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf) {
+ void *conf)
+{
#if ! defined(nginx_version)
@@ -473,40 +505,49 @@ static char*
}
-static char*
+
+static char *
ngx_http_echo_echo_duplicate(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
+ ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(echo_opcode_echo_duplicate,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_read_request_body(ngx_conf_t *cf,
- ngx_command_t *cmd, void *conf) {
+ ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(
echo_opcode_echo_read_request_body,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
-ngx_http_echo_echo_foreach_split(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
+
+static char *
+ngx_http_echo_echo_foreach_split(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(
echo_opcode_echo_foreach_split,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
-ngx_http_echo_echo_end(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
+
+static char *
+ngx_http_echo_echo_end(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
return ngx_http_echo_helper(
echo_opcode_echo_end,
echo_handler_cmd,
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_abort_parent(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
return ngx_http_echo_helper(
@@ -515,7 +556,8 @@ ngx_http_echo_echo_abort_parent(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
cf, cmd, conf);
}
-static char*
+
+static char *
ngx_http_echo_echo_exec(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
return ngx_http_echo_helper(
View
16 src/request_info.c → src/ngx_http_echo_request_info.c
@@ -1,9 +1,9 @@
#define DDEBUG 0
#include "ddebug.h"
-#include "request_info.h"
-#include "util.h"
-#include "handler.h"
+#include "ngx_http_echo_request_info.h"
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_handler.h"
#include <nginx.h>
@@ -86,12 +86,12 @@ ngx_http_echo_request_body_variable(ngx_http_request_t *r,
#if 0
- DD("rrr request_body null ? %d", r->request_body == NULL);
+ dd("rrr request_body null ? %d", r->request_body == NULL);
if (r->request_body) {
- DD("rrr request_body bufs null ? %d", r->request_body->bufs == NULL);
- DD("rrr request_body temp file ? %d", r->request_body->temp_file != NULL);
+ dd("rrr request_body bufs null ? %d", r->request_body->bufs == NULL);
+ dd("rrr request_body temp file ? %d", r->request_body->temp_file != NULL);
}
- DD("rrr request_body content length ? %ld", (long) r->headers_in.content_length_n);
+ dd("rrr request_body content length ? %ld", (long) r->headers_in.content_length_n);
#endif
@@ -231,7 +231,7 @@ ngx_http_echo_response_status_variable(ngx_http_request_t *r,
u_char *p;
if (r->headers_out.status) {
- DD("headers out status: %u", r->headers_out.status);
+ dd("headers out status: %u", r->headers_out.status);
p = ngx_palloc(r->pool, NGX_INT_T_LEN);
if (p == NULL) {
View
0  src/request_info.h → src/ngx_http_echo_request_info.h
File renamed without changes
View
34 src/sleep.c → src/ngx_http_echo_sleep.c
@@ -1,8 +1,8 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "sleep.h"
-#include "handler.h"
+
+#include "ngx_http_echo_sleep.h"
+#include "ngx_http_echo_handler.h"
#include <nginx.h>
#include <ngx_log.h>
@@ -30,12 +30,12 @@ ngx_http_echo_exec_echo_sleep(
return NGX_HTTP_BAD_REQUEST;
}
- DD("DELAY = %.02lf sec", delay);
+ dd("DELAY = %.02lf sec", delay);
#if defined(nginx_version) && nginx_version >= 8011
r->main->count++;
- DD("<> request main count : %u", r->main->count);
+ dd("<> request main count : %u", r->main->count);
#endif
@@ -49,22 +49,22 @@ ngx_http_echo_post_sleep(ngx_http_request_t *r) {
ngx_http_echo_ctx_t *ctx;
ngx_int_t rc;
- DD("entered echo post sleep...(r->done: %d)", r->done);
+ dd("entered echo post sleep...(r->done: %d)", r->done);
- DD("sleep: before get module ctx");
+ dd("sleep: before get module ctx");
ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module);
- DD("sleep: after get module ctx");
+ dd("sleep: after get module ctx");
if (ctx == NULL) {
return ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
}
- DD("timed out? %d", ctx->sleep.timedout);
- DD("timer set? %d", ctx->sleep.timer_set);
+ dd("timed out? %d", ctx->sleep.timedout);
+ dd("timer set? %d", ctx->sleep.timer_set);
if ( ! ctx->sleep.timedout ) {
- DD("HERE reached!");
+ dd("HERE reached!");
return;
}
ctx->sleep.timedout = 0;
@@ -72,8 +72,8 @@ ngx_http_echo_post_sleep(ngx_http_request_t *r) {
ctx->next_handler_cmd++;
if (ctx->sleep.timer_set) {
- DD("deleting timer for echo_sleep");
- DD("timer for echo_sleep deleted");
+ dd("deleting timer for echo_sleep");
+ dd("timer for echo_sleep deleted");
ngx_del_timer(&ctx->sleep);
}
@@ -85,7 +85,7 @@ ngx_http_echo_post_sleep(ngx_http_request_t *r) {
/*
if (rc == NGX_OK) {
r->main->count--;
- DD("<> request main count : %u", r->main->count);
+ dd("<> request main count : %u", r->main->count);
}
*/
@@ -121,11 +121,11 @@ ngx_http_echo_sleep_event_handler(ngx_event_t *ev) {
#if defined(nginx_version)
- DD("before run posted requests");
+ dd("before run posted requests");
ngx_http_run_posted_requests(c);
- DD("after run posted requests");
+ dd("after run posted requests");
#endif
@@ -147,7 +147,7 @@ ngx_http_echo_exec_echo_blocking_sleep(ngx_http_request_t *r,
return NGX_HTTP_BAD_REQUEST;
}
- DD("blocking DELAY = %.02lf sec", delay);
+ dd("blocking DELAY = %.02lf sec", delay);
ngx_msleep((ngx_msec_t) (1000 * delay));
View
0  src/sleep.h → src/ngx_http_echo_sleep.h
File renamed without changes
View
26 src/subrequest.c → src/ngx_http_echo_subrequest.c
@@ -1,9 +1,9 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "util.h"
-#include "subrequest.h"
-#include "handler.h"
+
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_subrequest.h"
+#include "ngx_http_echo_handler.h"
#define ngx_http_echo_method_name(m) { sizeof(m) - 1, (u_char *) m " " }
@@ -58,8 +58,8 @@ ngx_http_echo_exec_echo_subrequest_async(ngx_http_request_t *r,
return rc;
}
- DD("location: %s", parsed_sr->location->data);
- DD("location args: %s", (char*) (parsed_sr->query_string ?
+ dd("location: %s", parsed_sr->location->data);
+ dd("location args: %s", (char*) (parsed_sr->query_string ?
parsed_sr->query_string->data : (u_char*)"NULL"));
args.data = NULL;
@@ -317,7 +317,7 @@ ngx_http_echo_adjust_subrequest(ngx_http_request_t *sr, ngx_http_echo_subrequest
ngx_strlow(h->lowcase_key, h->key.data, h->key.len);
- DD("sr content length: %s", sr->headers_in.content_length->value.data);
+ dd("sr content length: %s", sr->headers_in.content_length->value.data);
}
return NGX_OK;
@@ -448,14 +448,14 @@ ngx_http_echo_exec_abort_parent(ngx_http_request_t *r,
ngx_chain_t *out = NULL;
/* ngx_int_t rc; */
- DD("aborting parent...");
+ dd("aborting parent...");
if (r == r->main || r->parent == NULL) {
return NGX_OK;
}
if (r->parent->postponed) {
- DD("Found parent->postponed...");
+ dd("Found parent->postponed...");
saved_data = r->connection->data;
ppr = NULL;
@@ -466,13 +466,13 @@ ngx_http_echo_exec_abort_parent(ngx_http_request_t *r,
if (pr->request == r) {
/* r->parent->postponed->next = pr; */
- DD("found the current subrequest");
+ dd("found the current subrequest");
out = pr->out;
continue;
}
/* r->connection->data = pr->request; */
- DD("finalizing the subrequest...");
+ dd("finalizing the subrequest...");
ngx_http_upstream_create(pr->request);
pr->request->upstream = NULL;
@@ -493,7 +493,7 @@ ngx_http_echo_exec_abort_parent(ngx_http_request_t *r,
r->connection->buffered = 0;
if (out != NULL) {
- DD("trying to send more stuffs for the parent");
+ dd("trying to send more stuffs for the parent");
ngx_http_output_filter(r->parent, out);
}
*/
@@ -504,7 +504,7 @@ ngx_http_echo_exec_abort_parent(ngx_http_request_t *r,
r->connection->data = saved_data;
}
- DD("terminating the parent request");
+ dd("terminating the parent request");
return ngx_http_echo_send_chain_link(r, ctx, NULL /* indicate LAST */);
View
0  src/subrequest.h → src/ngx_http_echo_subrequest.h
File renamed without changes
View
8 src/timer.c → src/ngx_http_echo_timer.c
@@ -2,7 +2,7 @@
#include "ddebug.h"
-#include "timer.h"
+#include "ngx_http_echo_timer.h"
#include <stdlib.h>
#include <ngx_log.h>
@@ -25,8 +25,8 @@ ngx_http_echo_timer_elapsed_variable(ngx_http_request_t *r,
ngx_time_update(0, 0); /* force the ngx timer to update */
tp = ngx_timeofday();
- DD("old sec msec: %ld %d\n", ctx->timer_begin.sec, ctx->timer_begin.msec);
- DD("new sec msec: %ld %d\n", tp->sec, tp->msec);
+ dd("old sec msec: %ld %d\n", ctx->timer_begin.sec, ctx->timer_begin.msec);
+ dd("new sec msec: %ld %d\n", tp->sec, tp->msec);
ms = (ngx_msec_int_t)
((tp->sec - ctx->timer_begin.sec) * 1000 +
@@ -48,7 +48,7 @@ ngx_http_echo_timer_elapsed_variable(ngx_http_request_t *r,
ngx_int_t
ngx_http_echo_exec_echo_reset_timer(ngx_http_request_t *r,
ngx_http_echo_ctx_t *ctx) {
- DD("Exec timer...");
+ dd("Exec timer...");
ngx_time_update(0, 0); /* force the ngx timer to update */
ctx->timer_begin = *ngx_timeofday();
View
0  src/timer.h → src/ngx_http_echo_timer.h
File renamed without changes
View
10 src/util.c → src/ngx_http_echo_util.c
@@ -1,8 +1,8 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "util.h"
-#include "sleep.h"
+
+#include "ngx_http_echo_util.h"
+#include "ngx_http_echo_sleep.h"
ngx_int_t
ngx_http_echo_init_ctx(ngx_http_request_t *r, ngx_http_echo_ctx_t **ctx_ptr) {
@@ -38,7 +38,7 @@ ngx_http_echo_eval_cmd_args(ngx_http_request_t *r,
}
arg = &arg_elts[i];
if (arg->lengths == NULL) { /* does not contain vars */
- DD("Using raw value \"%s\"", arg->raw_value.data);
+ dd("Using raw value \"%s\"", arg->raw_value.data);
*computed_arg = arg->raw_value;
} else {
if (ngx_http_script_run(r, computed_arg, arg->lengths->elts,
@@ -71,7 +71,7 @@ ngx_http_echo_send_chain_link(ngx_http_request_t* r,
size += p->buf->last - p->buf->pos;
}
}
- DD("content length for HTTP 1.0: %d", size);
+ dd("content length for HTTP 1.0: %d", size);
r->headers_out.content_length_n = (off_t) size;
if (r->headers_out.content_length) {
View
0  src/util.h → src/ngx_http_echo_util.h
File renamed without changes
View
10 src/var.c → src/ngx_http_echo_var.c
@@ -1,10 +1,10 @@
#define DDEBUG 0
-
#include "ddebug.h"
-#include "var.h"
-#include "timer.h"
-#include "request_info.h"
-#include "foreach.h"
+
+#include "ngx_http_echo_var.h"
+#include "ngx_http_echo_timer.h"
+#include "ngx_http_echo_request_info.h"
+#include "ngx_http_echo_foreach.h"
static ngx_int_t ngx_http_echo_incr_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
View
0  src/var.h → src/ngx_http_echo_var.h
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.