Skip to content

Commit

Permalink
fixed two bugs: 1. only free drizzle_res when it has a non-empty driz…
Browse files Browse the repository at this point in the history
…zle conntion associated; 2. ensure all the read/write timers get deleted before free the connection.
  • Loading branch information
agentzh committed Jan 8, 2010
1 parent 9e1f253 commit c797ac1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/ngx_http_upstream_drizzle.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ ngx_http_upstream_drizzle_get_peer(ngx_peer_connection_t *pc, void *data)

dp->drizzle_con = dc;

dd("creating drizzle con");

(void) drizzle_con_create(&dscf->drizzle, dc);

/* set protocol for the drizzle connection */
Expand Down Expand Up @@ -648,17 +650,36 @@ ngx_http_upstream_drizzle_free_peer(ngx_peer_connection_t *pc,
{
ngx_http_upstream_drizzle_peer_data_t *dp = data;
ngx_http_upstream_drizzle_srv_conf_t *dscf = dp->srv_conf;
ngx_event_t *rev, *wev;

dd("drizzle free peer");

drizzle_result_free(&dp->drizzle_res);
if (dp->drizzle_con && dp->drizzle_res.con) {
dd("before drizzle result free");

dd("%p vs. %p", dp->drizzle_res.con, dp->drizzle_con);

drizzle_result_free(&dp->drizzle_res);

dd("after drizzle result free");
}

if (dscf->max_cached) {
ngx_http_drizzle_keepalive_free_peer(pc, dp, dscf, state);
}

if (pc->connection) {
/* actually free the drizzle connection */
dd("actually free the drizzle connection");

rev = pc->connection->read;
if (rev->timer_set) {
ngx_del_timer(rev);
}

wev = pc->connection->write;
if (wev->timer_set) {
ngx_del_timer(wev);
}

ngx_http_upstream_drizzle_free_connection(pc->log, pc->connection,
dp->drizzle_con, dscf);
Expand Down

0 comments on commit c797ac1

Please sign in to comment.