diff --git a/server/core/service.c b/server/core/service.c index 9797bdaf8..9380d7c44 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -832,7 +832,7 @@ void serviceRemoveBackend(SERVICE *service, const SERVER *server) for (SERVER_REF *ref = service->dbref; ref; ref = ref->next) { - if (ref->server == server) + if (ref->server == server && ref->active) { ref->active = false; service->n_dbref--; @@ -856,8 +856,12 @@ serviceHasBackend(SERVICE *service, SERVER *server) spinlock_acquire(&service->spin); ptr = service->dbref; - while (ptr && ptr->server != server) + while (ptr) { + if (ptr->server == server && ptr->active) + { + break; + } ptr = ptr->next; } spinlock_release(&service->spin);