Permalink
Browse files

resolved conflicts while merging "master" into "thread".

  • Loading branch information...
2 parents c1f40cd + 07b9b3b commit b6cb3a1367e2c296a48e701e69b18209aa5475e7 @agentzh agentzh committed Sep 23, 2012
Showing with 74 additions and 46 deletions.
  1. +1 −1 src/ngx_http_lua_capturefilter.c
  2. +0 −26 src/ngx_http_lua_subrequest.c
  3. +53 −17 src/ngx_http_lua_util.c
  4. +0 −2 src/ngx_http_lua_util.h
  5. +20 −0 t/091-coroutine.t
@@ -149,6 +149,6 @@ ngx_http_lua_capture_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ngx_http_lua_discard_bufs(r->pool, in);
- return ngx_http_lua_flush_postponed_outputs(r);
+ return NGX_OK;
}
@@ -1272,9 +1272,6 @@ ngx_http_lua_subrequest(ngx_http_request_t *r,
ngx_connection_t *c;
ngx_http_request_t *sr;
ngx_http_core_srv_conf_t *cscf;
-#if 0
- ngx_http_postponed_request_t *pr, *p;
-#endif
r->main->subrequests--;
@@ -1358,33 +1355,10 @@ ngx_http_lua_subrequest(ngx_http_request_t *r,
sr->read_event_handler = ngx_http_request_empty_handler;
sr->write_event_handler = ngx_http_handler;
- if (c->data == r && r->postponed == NULL) {
- c->data = sr;
- }
-
sr->variables = r->variables;
sr->log_handler = r->log_handler;
-#if 0
- pr = ngx_palloc(r->pool, sizeof(ngx_http_postponed_request_t));
- if (pr == NULL) {
- return NGX_ERROR;
- }
-
- pr->request = sr;
- pr->out = NULL;
- pr->next = NULL;
-
- if (r->postponed) {
- for (p = r->postponed; p->next; p = p->next) { /* void */ }
- p->next = pr;
-
- } else {
- r->postponed = pr;
- }
-#endif
-
sr->internal = 1;
sr->discard_body = r->discard_body;
View
@@ -71,6 +71,10 @@ static void ngx_http_lua_del_thread(ngx_http_request_t *r, lua_State *L,
ngx_http_lua_ctx_t *ctx, ngx_http_lua_co_ctx_t *coctx);
static void ngx_http_lua_del_all_threads(ngx_http_request_t *r, lua_State *L,
ngx_http_lua_ctx_t *ctx);
+static ngx_int_t ngx_http_lua_output_filter(ngx_http_request_t *r,
+ ngx_chain_t *in);
+static ngx_int_t ngx_http_lua_send_special(ngx_http_request_t *r,
+ ngx_uint_t flags);
#ifndef LUA_PATH_SEP
@@ -486,7 +490,8 @@ ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
}
if (ctx->out) {
- rc = ngx_http_output_filter(r, ctx->out);
+
+ rc = ngx_http_lua_output_filter(r, ctx->out);
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
return rc;
@@ -511,7 +516,8 @@ ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"lua sending last buf of the response body");
- rc = ngx_http_send_special(r, NGX_HTTP_LAST);
+ rc = ngx_http_lua_send_special(r, NGX_HTTP_LAST);
+
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
return rc;
}
@@ -534,6 +540,50 @@ ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
return NGX_OK;
}
+ return ngx_http_lua_output_filter(r, in);
+}
+
+
+static ngx_int_t
+ngx_http_lua_send_special(ngx_http_request_t *r, ngx_uint_t flags)
+{
+ ngx_int_t rc;
+ ngx_http_request_t *ar; /* active request */
+
+ ar = r->connection->data;
+
+ if (ar != r) {
+
+ /* bypass ngx_http_postpone_filter_module */
+
+ r->connection->data = r;
+ rc = ngx_http_send_special(r, flags);
+ r->connection->data = ar;
+ return rc;
+ }
+
+ return ngx_http_send_special(r, flags);
+}
+
+
+static ngx_int_t
+ngx_http_lua_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
+{
+ ngx_int_t rc;
+ ngx_http_request_t *ar; /* active request */
+
+ ar = r->connection->data;
+
+ if (ar != r) {
+
+ /* bypass ngx_http_postpone_filter_module */
+
+ r->connection->data = r;
+ rc = ngx_http_output_filter(r, in);
+ r->connection->data = ar;
+ return rc;
+ }
+
return ngx_http_output_filter(r, in);
}
@@ -1306,7 +1356,7 @@ ngx_http_lua_wev_handler(ngx_http_request_t *r)
"lua wev handler flushing output: buffered 0x%uxd",
c->buffered);
- rc = ngx_http_output_filter(r, NULL);
+ rc = ngx_http_lua_output_filter(r, NULL);
if (rc == NGX_ERROR || rc > NGX_OK) {
if (ctx->entered_content_phase) {
@@ -1451,20 +1501,6 @@ ngx_http_lua_digest_hex(u_char *dest, const u_char *buf, int buf_len)
}
-ngx_int_t
-ngx_http_lua_flush_postponed_outputs(ngx_http_request_t *r)
-{
- if (r == r->connection->data && r->postponed) {
- /* notify the downstream postpone filter to flush the postponed
- * outputs of the current request */
- return ngx_http_lua_next_body_filter(r, NULL);
- }
-
- /* do nothing */
- return NGX_OK;
-}
-
-
void
ngx_http_lua_set_multi_value_table(lua_State *L, int index)
{
View
@@ -96,8 +96,6 @@ ngx_int_t ngx_http_lua_wev_handler(ngx_http_request_t *r);
u_char * ngx_http_lua_digest_hex(u_char *dest, const u_char *buf,
int buf_len);
-ngx_int_t ngx_http_lua_flush_postponed_outputs(ngx_http_request_t *r);
-
void ngx_http_lua_set_multi_value_table(lua_State *L, int index);
void ngx_http_lua_unescape_uri(u_char **dst, u_char **src, size_t size,
View
@@ -903,3 +903,23 @@ parent: status: running
--- error_log
lua coroutine: runtime error: [string "content_by_lua"]:4: bad
+
+
+=== TEST 22: entry coroutine is yielded by hand and still gets the right status
+--- config
+ location /t {
+ content_by_lua '
+ local co = coroutine.running()
+ ngx.say("status: ", coroutine.status(co))
+ coroutine.yield(co)
+ ngx.say("status: ", coroutine.status(co))
+ ';
+ }
+--- request
+GET /t
+--- response_body
+status: running
+status: running
+--- no_error_log
+[error]
+

0 comments on commit b6cb3a1

Please sign in to comment.