Additional fixes/test. We will now limit the hostname when adding it into
[m6w6/libmemcached] / libmemcached / hosts.c
index 7034d3ec366dd5288ad9b8783b5ee2ca24a356a3..c861a6d9361ede3ff48c7aa5bc3cfccaaa321f9c 100644 (file)
@@ -17,6 +17,7 @@ static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
                                      in_port_t port,
                                      uint32_t weight,
                                      memcached_connection_t type);
+
 static memcached_return_t update_continuum(memcached_st *ptr);
 
 static int compare_servers(const void *p1, const void *p2)
@@ -449,3 +450,20 @@ static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
 
   return run_distribution(ptr);
 }
+
+memcached_return_t memcached_server_add_parsed(memcached_st *ptr,
+                                               const char *hostname,
+                                               size_t hostname_length,
+                                               in_port_t port,
+                                               uint32_t weight)
+{
+  char buffer[NI_MAXHOST];
+
+  memcpy(buffer, hostname, hostname_length);
+  buffer[hostname_length]= 0;
+
+  return server_add(ptr, buffer,
+                    port,
+                    weight,
+                    MEMCACHED_CONNECTION_TCP);
+}