Skip to content

Commit

Permalink
Bugfix with closing a busy, waiting connection.
Browse files Browse the repository at this point in the history
Be sure to process reserved jobs after removing the connection from
any list it is in, especially the waiting list.

There was a problem while closing a connection that both has reserved
jobs and is waiting for a job. Processing the reserved jobs before
removing the closing connection from the wait list (i.e. in the wrong
order) was causing us to try to assign a reserved job to the same
connection that is in the process of being closed, possibly failing to
assign a job to another valid connection, closing this connection
twice, and corrupting the stats.
  • Loading branch information
Keith Rarick committed Nov 7, 2007
1 parent 96d18c7 commit 992d7a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* Doubly-linked list of free connections. */
static struct conn pool = { &pool, &pool, 0 };

int cur_conn_ct = 0, cur_worker_ct = 0, cur_producer_ct = 0;
static int cur_conn_ct = 0, cur_worker_ct = 0, cur_producer_ct = 0;

static conn
conn_alloc()
Expand Down Expand Up @@ -160,10 +160,8 @@ conn_close(conn c)
/* was this a peek or stats command? */
if (!has_reserved_this_job(c, c->out_job)) free(c->out_job);

if (has_reserved_job(c)) enqueue_reserved_jobs(c);
c->in_job = c->out_job = NULL;


if (c->type & CONN_TYPE_PRODUCER) cur_producer_ct--; /* stats */
if (c->type & CONN_TYPE_WORKER) cur_worker_ct--; /* stats */

Expand All @@ -172,5 +170,7 @@ conn_close(conn c)
unbrake(NULL);
remove_waiting_conn(c);
conn_remove(c);
if (has_reserved_job(c)) enqueue_reserved_jobs(c);

conn_free(c);
}

0 comments on commit 992d7a3

Please sign in to comment.