{
for (x= 0; x < ptr->number_of_hosts; x++)
{
- if (ptr->hosts[x].fd == -1)
+ if (ptr->hosts[x].fd > 0)
close(ptr->hosts[x].fd);
+
free(ptr->hosts[x].hostname);
}
ptr->hosts= (memcached_host_st *)realloc(ptr->hosts, sizeof(memcached_host_st) * (ptr->number_of_hosts+1));
memset(ptr->hosts, 0, sizeof(memcached_host_st) * (size_t)ptr->number_of_hosts);
ptr->hosts[ptr->number_of_hosts].hostname=
- (char *)malloc(sizeof(char) * (strlen(hostname) + 1));
- memset(ptr->hosts[ptr->number_of_hosts].hostname, 0, sizeof(char) * (strlen(hostname) + 1));
+ (char *)malloc(sizeof(char) * (strlen(hostname)+1));
+ memset(ptr->hosts[ptr->number_of_hosts].hostname, 0, strlen(hostname)+1);
memcpy(ptr->hosts[ptr->number_of_hosts].hostname, hostname, strlen(hostname));
ptr->hosts[ptr->number_of_hosts].port= port;
ptr->hosts[ptr->number_of_hosts].fd= -1;
else
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
- case 'E': /* PROTOCOL ERROR */
- return MEMCACHED_PROTOCOL_ERROR;
+ case 'E': /* PROTOCOL ERROR or END */
+ {
+ if (buffer[1] == 'N')
+ return MEMCACHED_NOTFOUND;
+ else if (buffer[1] == 'R')
+ return MEMCACHED_PROTOCOL_ERROR;
+ else
+ return MEMCACHED_UNKNOWN_READ_FAILURE;
+ }
case 'C': /* CLIENT ERROR */
return MEMCACHED_CLIENT_ERROR;
default:
string= memcached_get(memc, key, strlen(key),
&string_length, &flags, &rc);
- printf("RC %u\n", rc);
assert(rc == MEMCACHED_NOTFOUND);
assert(string_length == 0);
assert(!string);