Skip to content

Commit

Permalink
Fix #862 - wrong waiting connection count stat.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rarick committed Nov 7, 2007
1 parent 60b7903 commit 96d18c7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ conn_close(conn c)
cur_conn_ct--; /* stats */

unbrake(NULL);
remove_waiting_conn(c);
conn_remove(c);
conn_free(c);
}
1 change: 1 addition & 0 deletions conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
/* CONN_TYPE_* are bit masks */
#define CONN_TYPE_PRODUCER 1
#define CONN_TYPE_WORKER 2
#define CONN_TYPE_WAITING 4

typedef struct conn *conn;

Expand Down
11 changes: 7 additions & 4 deletions prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ reply_job(conn c, job j, const char *word)
return reply(c, c->reply_buf, strlen(c->reply_buf), STATE_SENDJOB);
}

static conn
next_waiting_conn()
conn
remove_waiting_conn(conn c)
{
if (!(c->type & CONN_TYPE_WAITING)) return NULL;
c->type &= ~CONN_TYPE_WAITING;
waiting_ct--;
return conn_remove(wait_queue.next);
return conn_remove(c);
}

void
Expand All @@ -77,7 +79,7 @@ process_queue()
j = pq_take(ready_q);
if (!j) return;
if (j->pri < URGENT_THRESHOLD) urgent_ct--;
reserve_job(next_waiting_conn(), j);
reserve_job(remove_waiting_conn(wait_queue.next), j);
}
}

Expand Down Expand Up @@ -140,6 +142,7 @@ void
enqueue_waiting_conn(conn c)
{
waiting_ct++;
c->type |= CONN_TYPE_WAITING;
conn_insert(&wait_queue, conn_remove(c) ? : c);
}

Expand Down
1 change: 1 addition & 0 deletions prot.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void prot_init();
void reply(conn c, char *line, int len, int state);
void reply_job(conn c, job j, const char *word);

conn remove_waiting_conn(conn c);
void enqueue_waiting_conn(conn c);

int enqueue_job(job j);
Expand Down
1 change: 0 additions & 1 deletion reserve.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ reserve_job(conn c, job j)
{
j->deadline = time(NULL) + RESERVATION_TIMEOUT;
cur_reserved_ct++; /* stats */
conn_remove(c);
conn_insert(&running, c);
j->state = JOB_STATE_RESERVED;
job_insert(&c->reserved_jobs, j);
Expand Down

0 comments on commit 96d18c7

Please sign in to comment.