Skip to content

Instantly share code, notes, and snippets.

@agentzh
Created January 5, 2014 19:24
Show Gist options
  • Select an option

  • Save agentzh/8272614 to your computer and use it in GitHub Desktop.

Select an option

Save agentzh/8272614 to your computer and use it in GitHub Desktop.
diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c
index 0dcd9e8..0311f8f 100644
--- a/src/ngx_http_lua_socket_tcp.c
+++ b/src/ngx_http_lua_socket_tcp.c
@@ -3967,17 +3967,35 @@ ngx_http_lua_socket_downstream_destroy(lua_State *L)
static void
ngx_http_lua_req_socket_cleanup(void *data)
{
+ ngx_event_t *wev, *rev;
+ ngx_connection_t *c;
+ ngx_http_lua_ctx_t *ctx;
+ ngx_http_request_t *r;
ngx_http_lua_socket_tcp_upstream_t *u = data;
-#if (NGX_DEBUG)
- ngx_http_request_t *r;
-
r = u->request;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"cleanup lua tcp socket downstream request: \"%V\"",
&r->uri);
-#endif
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
+ if (ctx && ctx->writing_raw_req_socket) {
+ ctx->writing_raw_req_socket = 0;
+ }
+
+ c = r->connection;
+ c->error = 1;
+
+ wev = c->write;
+ if (wev->timer_set) {
+ ngx_del_timer(wev);
+ }
+
+ rev = c->read;
+ if (rev->timer_set) {
+ ngx_del_timer(rev);
+ }
if (u->cleanup) {
*u->cleanup = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment