Skip to content
Browse files

remove from thread.actve_conn when conn_close

  • Loading branch information...
1 parent ccfa8a0 commit 5a558c39da14b1787e7a48eb70f604fe483bbda3 @davies committed May 28, 2012
Showing with 15 additions and 9 deletions.
  1. +12 −0 memcached.c
  2. +3 −9 thread.c
View
12 memcached.c
@@ -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;
View
12 thread.c
@@ -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);

0 comments on commit 5a558c3

Please sign in to comment.
Something went wrong with that request. Please try again.