- servAddr.sin_family= h->h_addrtype;
- memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
- servAddr.sin_port = htons(ptr->hosts[server_key].port);
+ addrlen= strlen(servAddr.sun_path) + sizeof(servAddr.sun_family);
+
+test_connect:
+ if (connect(ptr->hosts[server_key].fd,
+ (struct sockaddr *)&servAddr,
+ sizeof(servAddr)) < 0)
+ {
+ switch (errno) {
+ /* We are spinning waiting on connect */
+ case EALREADY:
+ case EINPROGRESS:
+ case EINTR:
+ goto test_connect;
+ case EISCONN: /* We were spinning waiting on connect */
+ break;
+ default:
+ WATCHPOINT_ERRNO(errno);
+ ptr->cached_errno= errno;
+ return MEMCACHED_ERRNO;
+ }
+ ptr->connected++;
+ }
+ }
+ return MEMCACHED_SUCCESS;
+}
+
+static memcached_return udp_connect(memcached_st *ptr, unsigned int server_key)
+{
+ if (ptr->hosts[server_key].fd == -1)
+ {
+ /* Old connection junk still is in the structure */
+ WATCHPOINT_ASSERT(ptr->hosts[server_key].cursor_active == 0);
+
+ /*
+ If we have not allocated the hosts object.
+ Or if the cache has not been set.
+ */
+ if (ptr->hosts[server_key].sockaddr_inited == MEMCACHED_NOT_ALLOCATED ||
+ (!(ptr->flags & MEM_USE_CACHE_LOOKUPS)))
+ {
+ memcached_return rc;
+
+ rc= set_hostinfo(&ptr->hosts[server_key]);
+ if (rc != MEMCACHED_SUCCESS)
+ return rc;
+
+ ptr->hosts[server_key].sockaddr_inited= MEMCACHED_ALLOCATED;
+ }