Skip to content

Commit

Permalink
remove from thread.actve_conn when conn_close
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed May 30, 2012
1 parent ccfa8a0 commit 5a558c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 12 additions & 0 deletions memcached.c
Expand Up @@ -460,6 +460,18 @@ static void conn_cleanup(conn *c) {
}
}

conn *cc = c->thread->active_conn;
if (c == cc) {
c->thread->active_conn = c->next;
} else {
while (NULL != cc && cc->next != c) {
cc = cc->next;
}
if (NULL != cc) {
cc->next = c->next;
}
}

if (c->write_and_free) {
free(c->write_and_free);
c->write_and_free = 0;
Expand Down
12 changes: 3 additions & 9 deletions thread.c
Expand Up @@ -269,16 +269,10 @@ static void thread_libevent_process(int fd, short which, void *arg) {
/* kick the oldest connection */
conn *c = me->active_conn;
if (NULL != c) {
if (NULL != c->next) {
while (NULL != c->next->next) {
c = c->next;
}
conn_close(c->next);
c->next = NULL;
} else {
conn_close(c);
me->active_conn = NULL;
while (NULL != c->next) {
c = c->next;
}
conn_close(c);
}

cqi_free(item);
Expand Down

0 comments on commit 5a558c3

Please sign in to comment.