ngx_int_t ngx_http_echo_handler(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_echo_ctx_t *ctx; system("echo ngx_http_echo_handler >>/data/a.log"); dd("subrequest in memory: %d", (int) r->subrequest_in_memory); dd("haoning haohao subrequest in memory: %d", (int) r->subrequest_in_memory); rc = ngx_http_echo_run_cmds(r); dd("run cmds returned %d", (int) rc); if (rc == NGX_OK || rc == NGX_DONE || rc == NGX_DECLINED) { return rc; } if (rc == NGX_ERROR) { return rc; } ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module); if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { if (ctx && r->header_sent) { return NGX_ERROR; } return rc; } /* rc == NGX_AGAIN */ #if defined(nginx_version) && nginx_version >= 8011 r->main->count++; #endif dd("%d", r->connection->destroyed); dd("%d", r->done); if (ctx) { dd("mark busy %d for %.*s", (int) ctx->next_handler_cmd, (int) r->uri.len, r->uri.data); ctx->waiting = 1; ctx->done = 0; } return NGX_DONE; }
ngx_int_t ngx_http_echo_handler(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_echo_ctx_t *ctx; rc = ngx_http_echo_run_cmds(r); if (rc == NGX_ERROR) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { return rc; } if (rc == NGX_DONE) { return NGX_DONE; } if (rc == NGX_AGAIN) { #if defined(nginx_version) && nginx_version >= 8011 r->main->count++; #endif /* XXX we need this for 0.7.x and 0.8.x < 0.8.11 */ dd("%d", r->connection->destroyed); dd("%d", r->done); ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module); if (ctx) { dd("mark busy %d", (int) ctx->next_handler_cmd); ctx->waiting = 1; ctx->done = 0; } return NGX_DONE; } return NGX_OK; }
void ngx_http_echo_wev_handler(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_echo_ctx_t *ctx; dd_enter(); ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module); if (ctx == NULL) { ngx_http_finalize_request(r, NGX_ERROR); return; } if (ctx->waiting && ! ctx->done) { if (r->main->posted_requests && r->main->posted_requests->request != r) { dd("HOT SPIN"); #if defined(nginx_version) && nginx_version >= 8012 ngx_http_post_request(r, NULL); #else ngx_http_post_request(r); #endif return; } } ctx->done = 0; ctx->next_handler_cmd++; rc = ngx_http_echo_run_cmds(r); dd("rc: %d", (int) rc); if (rc == NGX_DONE) { return; } if (rc == NGX_AGAIN) { dd("mark busy %d", (int) ctx->next_handler_cmd); ctx->waiting = 1; ctx->done = 0; } else { dd("mark ready %d", (int) ctx->next_handler_cmd); ctx->waiting = 0; ctx->done = 1; dd("finalizing with rc %d", (int) rc); dd("finalize request %.*s with %d", (int) r->uri.len, r->uri.data, (int) rc); ngx_http_finalize_request(r, rc); } }
void ngx_http_echo_wev_handler(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_echo_ctx_t *ctx; dd("wev handler"); ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module); if (ctx == NULL) { ngx_http_finalize_request(r, NGX_ERROR); return; } dd("waiting: %d, done: %d", (int) ctx->waiting, (int) ctx->done); if (ctx->waiting && ! ctx->done) { if (r == r->connection->data && r->postponed) { if (r->postponed->request) { r->connection->data = r->postponed->request; #if defined(nginx_version) && nginx_version >= 8012 ngx_http_post_request(r->postponed->request, NULL); #else ngx_http_post_request(r->postponed->request); #endif } else { ngx_http_echo_flush_postponed_outputs(r); } } return; } ctx->done = 0; ctx->next_handler_cmd++; rc = ngx_http_echo_run_cmds(r); dd("rc: %d", (int) rc); if (rc == NGX_DONE) { ngx_http_finalize_request(r, rc); return; } if (rc == NGX_AGAIN) { dd("mark busy %d for %.*s", (int) ctx->next_handler_cmd, (int) r->uri.len, r->uri.data); ctx->waiting = 1; ctx->done = 0; } else { dd("mark ready %d", (int) ctx->next_handler_cmd); ctx->waiting = 0; ctx->done = 1; dd("finalizing with rc %d", (int) rc); dd("finalize request %.*s with %d", (int) r->uri.len, r->uri.data, (int) rc); ngx_http_finalize_request(r, rc); } }
ngx_int_t ngx_http_echo_handler(ngx_http_request_t *r) { ngx_int_t rc; ngx_http_echo_ctx_t *ctx; ngx_log_stderr(0, "haoning---- ngx_http_echo_handler\"%s\"","ngx_http_echo_handler.c" ); system("echo 'ngx_http_echo_handler' >> /data/ngx_http_echo_handler.log"); dd("subrequest in memory: %d", (int) r->subrequest_in_memory); dd("haoning haohao subrequest in memory: %d", (int) r->subrequest_in_memory); dd("haoning haohao r->method in : %d",(int) r->method); dd("haoning haohao r->http_version: %d",(int) r->http_version) ; dd("haoning haohao r->request_line.data: %s",r->request_line.data) ; dd("haoning haohao r->uri.data): %s",r->uri.data); dd("haoning haohao r->args.data: %s",r->args.data); dd("haoning haohao r->exten.data: %s",r->exten.data); dd("haoning haohao r->unparsed_uri.data: %s",r->unparsed_uri.data); dd("haoning haohao r->method_name.data: %s",r->method_name.data) ; dd("haoning haohao r->http_protocol.data: %s",r->http_protocol.data); rc = ngx_http_echo_run_cmds(r); dd("run cmds returned %d", (int) rc); if (rc == NGX_OK || rc == NGX_DONE || rc == NGX_DECLINED) { return rc; } if (rc == NGX_ERROR) { return rc; } ctx = ngx_http_get_module_ctx(r, ngx_http_echo_module); if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { if (ctx && r->header_sent) { return NGX_ERROR; } return rc; } /* rc == NGX_AGAIN */ #if defined(nginx_version) && nginx_version >= 8011 r->main->count++; #endif dd("%d", r->connection->destroyed); dd("%d", r->done); if (ctx) { dd("mark busy %d for %.*s", (int) ctx->next_handler_cmd, (int) r->uri.len, r->uri.data); ctx->waiting = 1; ctx->done = 0; } return NGX_DONE; }