Permalink
Browse files

bugfix: we closed the mysql connection twice by calling ngx_close_con…

…nection.
  • Loading branch information...
1 parent 2dc0a3c commit 1a53f5f8b0b7f248087482d314b35eb60cba2b71 @agentzh agentzh committed Aug 17, 2012
Showing with 41 additions and 1 deletion.
  1. +41 −1 src/ngx_http_drizzle_upstream.c
@@ -931,6 +931,8 @@ ngx_http_upstream_drizzle_free_connection(ngx_log_t *log,
ngx_connection_t *c, drizzle_con_st *dc,
ngx_http_upstream_drizzle_srv_conf_t *dscf)
{
+ ngx_event_t *rev, *wev;
+
dd("drizzle free peer connection");
dscf->active_conns--;
@@ -943,7 +945,45 @@ ngx_http_upstream_drizzle_free_connection(ngx_log_t *log,
}
if (c) {
- ngx_close_connection(c);
+ /* dd("c pool: %p", c->pool); */
+ rev = c->read;
+ wev = c->write;
+
+ if (rev->timer_set) {
+ ngx_del_timer(rev);
+ }
+
+ if (wev->timer_set) {
+ ngx_del_timer(wev);
+ }
+
+ if (ngx_del_conn) {
+ ngx_del_conn(c, NGX_CLOSE_EVENT);
+
+ } else {
+ if (rev->active || rev->disabled) {
+ ngx_del_event(rev, NGX_READ_EVENT, NGX_CLOSE_EVENT);
+ }
+
+ if (wev->active || wev->disabled) {
+ ngx_del_event(wev, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
+ }
+ }
+
+ if (rev->prev) {
+ ngx_delete_posted_event(rev);
+ }
+
+ if (wev->prev) {
+ ngx_delete_posted_event(wev);
+ }
+
+ rev->closed = 1;
+ wev->closed = 1;
+
+ ngx_free_connection(c);
+
+ c->fd = (ngx_socket_t) -1;
}
}

0 comments on commit 1a53f5f

Please sign in to comment.