Refactor auxiliary routing functions

Refactored some of the functions used to calculate servers. Removed
redundant checks and moved the ack_write() call to the right place.
This commit is contained in:
Markus Mäkelä
2017-06-15 20:30:11 +03:00
parent 1f31cfdfd7
commit b48bb4fc5e
3 changed files with 26 additions and 36 deletions

View File

@ -79,8 +79,8 @@ static bool valid_for_slave(const SERVER *server, const SERVER *master_host)
* @param cmpfun qsort() compatible comparison function
* @return The best slave backend reference or NULL if no candidates could be found
*/
SRWBackend* get_slave_candidate(ROUTER_CLIENT_SES* rses, const SERVER *master,
int (*cmpfun)(const void *, const void *))
SRWBackend get_slave_candidate(ROUTER_CLIENT_SES* rses, const SERVER *master,
int (*cmpfun)(const void *, const void *))
{
SRWBackend candidate;
@ -210,7 +210,7 @@ bool select_connect_backend_servers(int router_nservers,
ss_dassert(slaves_connected < max_nslaves || max_nslaves == 0);
/** Connect to all possible slaves */
for (SRWBackend bref(get_slave_candidate(rses, router_nservers, master_host, cmpfun));
for (SRWBackend bref(get_slave_candidate(rses, master_host, cmpfun));
bref && slaves_connected < max_nslaves;
bref = get_slave_candidate(rses, master_host, cmpfun))
{