X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fserver_list.c;h=ca37f7f9a4b3f159e5f8747d50be33c4918a3698;hb=c4dbc7e56b01545e25bc95ba122c79d4a2631a99;hp=9287bc199ec2776af704e546c30164891e6955e3;hpb=83607be3d20de2cc96dd588bd418d0e407ffa726;p=awesomized%2Flibmemcached diff --git a/libmemcached/server_list.c b/libmemcached/server_list.c index 9287bc19..ca37f7f9 100644 --- a/libmemcached/server_list.c +++ b/libmemcached/server_list.c @@ -24,7 +24,9 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr, if (hostname == NULL || error == NULL) return NULL; - if (! port) + if (hostname[0] == '/') + port = 0; + else if (! port) port= MEMCACHED_DEFAULT_PORT; /* Increment count for hosts */ @@ -37,12 +39,16 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr, new_host_list= (memcached_server_write_instance_st)realloc(ptr, sizeof(memcached_server_st) * count); if (!new_host_list) { + ptr->cached_errno= errno; *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; } - /* TODO: Check return type */ - memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, MEMCACHED_CONNECTION_TCP); + /* @todo Check return type */ + memcached_server_create_with(NULL, &new_host_list[count-1], hostname, port, weight, port ? MEMCACHED_CONNECTION_TCP : MEMCACHED_CONNECTION_UNIX_SOCKET); + + // Handset allocated since + new_host_list->options.is_allocated= true; /* Backwards compatibility hack */ memcached_servers_set_count(new_host_list, count);