same order.
* Added get_by_key, set_by_key tests for C++ API
* Fix for limit_maxbytes to be 64bit in stats
* Added Atom Smasher test (scale baby, scale!)
+ * Servers are now sorted, meaning that servers are now ordered so that
+ clients with the same lists, will have same distribution. (Idea from
+ Ross McFarland).
0.15 Tue Jan 29 14:55:44 PST 2008
* More work on the C++ API.
Andre Cruz - Help with getting the CRC Hash function to match other connectors
Brian Pontz - Hsieh hash
Tim Bunce - Perl Driver work and feedback on API
+Ross McFarland - Idea for sorting servers.
}
}
+static int compare_servers(const void *p1, const void *p2)
+{
+ int return_value;
+ memcached_server_st *a= (memcached_server_st *)p1;
+ memcached_server_st *b= (memcached_server_st *)p2;
+
+ return_value= strcmp(a->hostname, b->hostname);
+
+ if (return_value == 0)
+ {
+ if (a->port > b->port)
+ return_value++;
+ else
+ return_value--;
+ }
+
+ return return_value;
+}
+
static void host_reset(memcached_st *ptr, memcached_server_st *host,
char *hostname, unsigned int port,
memcached_connection type)
}
ptr->hosts[0].count= ptr->number_of_hosts;
+ if (ptr->number_of_hosts > 1)
+ qsort(ptr->hosts, ptr->number_of_hosts, sizeof(memcached_server_st), compare_servers);
+
rebalance_wheel(ptr);
return MEMCACHED_SUCCESS;
ptr->number_of_hosts++;
ptr->hosts[0].count++;
+ if (ptr->number_of_hosts > 1)
+ qsort(ptr->hosts, ptr->number_of_hosts, sizeof(memcached_server_st), compare_servers);
+
rebalance_wheel(ptr);
LIBMEMCACHED_MEMCACHED_SERVER_ADD_END();
/* Backwards compatibility hack */
new_host_list[0].count++;
+ count= new_host_list[0].count;
+
+ if (new_host_list[0].count > 1)
+ qsort(new_host_list, count, sizeof(memcached_server_st), compare_servers);
+
+ new_host_list[0].count= count;
+
*error= MEMCACHED_SUCCESS;
return new_host_list;
return 0;
}
+uint8_t server_sort_test(memcached_st *ptr)
+{
+ memcached_server_st *server_list;
+ memcached_return rc;
+
+ server_list= memcached_server_list_append(NULL, "arg", 0, &rc);
+ assert(server_list);
+
+ server_list= memcached_server_list_append(server_list, "localhost", 0, &rc);
+ assert(server_list);
+
+ server_list= memcached_server_list_append(server_list, "c", 0, &rc);
+ assert(server_list);
+
+ server_list= memcached_server_list_append(server_list, "abba", 0, &rc);
+ assert(server_list);
+
+ free(server_list);
+
+ return 0;
+}
+
uint8_t allocation_test(memcached_st *not_used)
{
memcached_st *memc;
{"init", 0, init_test },
{"allocation", 0, allocation_test },
{"server_list_null_test", 0, server_list_null_test},
+ {"server_sort", 0, server_sort_test},
{"clone_test", 0, clone_test },
{"error", 0, error_test },
{"set", 0, set_test },
}
else
{
- WATCHPOINT;
{
char server_string_buffer[8096];
char *end_ptr;