Skip to content
New issue

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

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

Already on GitHub? # to your account

Incorrect fallthrough in memcached_behavior_set for REMOVE_FAILED_SERVERS #35

Closed
m6w6 opened this issue Jan 20, 2020 · 1 comment
Closed

Comments

@m6w6
Copy link
Collaborator

m6w6 commented Jan 20, 2020

Imported from Launchpad using lp2gh.


memcached_behavior_set contains the following two cases, the first falls through into the second:

  case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS:
    ptr->flags.auto_eject_hosts= bool(data);

  case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT:
    if (data == 0)
    {
      return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
                                        memcached_literal_param("MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT requires a value greater then zero."));
    }
    ptr->server_failure_limit= uint32_t(data);
    break;

Having zero data for the first is perfectly valid (it means "don't remove failed servers,"), when when we fall through, it causes an error. There should be a "break" at the end of that first case block.

@m6w6 m6w6 added the New label Jan 20, 2020
@m6w6
Copy link
Collaborator Author

m6w6 commented Jan 20, 2020


There's a corresponding problem in memcached_behavior_get:

case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS:
case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT:
return ptr->server_failure_limit;

should read:

case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS:
return ptr->flags.auto_eject_hosts;

case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT:
return ptr->server_failure_limit;

@m6w6 m6w6 removed the New label Jan 20, 2020
@m6w6 m6w6 closed this as completed in f30bca7 Jan 21, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant