+
+ if (ptr->fd == -1)
+ return MEMCACHED_ERRNO; /* The last error should be from connect() */
+
+ return MEMCACHED_SUCCESS; /* The last error should be from connect() */
+}
+
+
+memcached_return memcached_connect(memcached_server_st *ptr)
+{
+ memcached_return rc= MEMCACHED_NO_SERVERS;
+ LIBMEMCACHED_MEMCACHED_CONNECT_START();
+
+ if (ptr->root->retry_timeout)
+ {
+ struct timeval next_time;
+
+ gettimeofday(&next_time, NULL);
+ if (next_time.tv_sec < ptr->next_retry)
+ return MEMCACHED_TIMEOUT;
+ }
+ /* We need to clean up the multi startup piece */
+ switch (ptr->type)
+ {
+ case MEMCACHED_CONNECTION_UNKNOWN:
+ WATCHPOINT_ASSERT(0);
+ rc= MEMCACHED_NOT_SUPPORTED;
+ break;
+ case MEMCACHED_CONNECTION_UDP:
+ case MEMCACHED_CONNECTION_TCP:
+ rc= network_connect(ptr);
+ break;
+ case MEMCACHED_CONNECTION_UNIX_SOCKET:
+ rc= unix_socket_connect(ptr);
+ break;
+ default:
+ WATCHPOINT_ASSERT(0);
+ }
+
+ if (rc != MEMCACHED_SUCCESS)
+ WATCHPOINT_ERROR(rc);
+