Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for dead memcache server buggy? #1229

Closed
rpluem-vf opened this issue Jun 18, 2024 · 1 comment
Closed

Checking for dead memcache server buggy? #1229

rpluem-vf opened this issue Jun 18, 2024 · 1 comment
Labels

Comments

@rpluem-vf
Copy link
Contributor

In

rc = rc && (context->cache_memcache->live_servers[0]->status != APR_MC_SERVER_DEAD);

doesn't it need to be

rc = rc && (context->cache_memcache->live_servers[i]->status != APR_MC_SERVER_DEAD); 

because otherwise I don't see how we iterate over all servers as the loop body in

for (i = 0; rc && i < context->cache_memcache->ntotal; i++)
rc = rc && (context->cache_memcache->live_servers[0]->status != APR_MC_SERVER_DEAD);

is invariant as neither i is used nor the array pointer of live_servers gets incremented.

Furthermore, what should be tested? That all servers are up? In this case the check would be correct, but I guess we would like to check that a least one server is up and hence the check would need to be:

	int rc = FALSE;
	int i;
	for (i = 0; !rc && i < context->cache_memcache->ntotal; i++)
		rc = rc || (context->cache_memcache->live_servers[i]->status != APR_MC_SERVER_DEAD);
	return rc;

or

	int i;
	for (i = 0;  i < context->cache_memcache->ntotal; i++) {
		if (context->cache_memcache->live_servers[i]->status != APR_MC_SERVER_DEAD)
		    return TRUE;
        }
	return FALSE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant