Skip to content

Commit

Permalink
bugfix: socket leak would happen when the mysql connection pool was u…
Browse files Browse the repository at this point in the history
…sed.
  • Loading branch information
agentzh committed Aug 16, 2012
1 parent b05c67f commit 209826b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
2 changes: 2 additions & 0 deletions src/ngx_http_drizzle_keepalive.c
Expand Up @@ -395,6 +395,8 @@ ngx_http_drizzle_keepalive_close_handler(ngx_event_t *ev)
item = c->data;
dscf = item->srv_conf;

dd("closing fd %d", c->fd);

ngx_http_upstream_drizzle_free_connection(ev->log, c, item->drizzle_con,
dscf);

Expand Down
40 changes: 1 addition & 39 deletions src/ngx_http_drizzle_upstream.c
Expand Up @@ -931,8 +931,6 @@ 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--;
Expand All @@ -945,43 +943,7 @@ ngx_http_upstream_drizzle_free_connection(ngx_log_t *log,
}

if (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);
ngx_close_connection(c);
}
}

Expand Down

0 comments on commit 209826b

Please sign in to comment.