From: Brian Aker Date: Fri, 16 Nov 2007 21:40:36 +0000 (-0800) Subject: Possible fix for problem where servaddr may not always be correctly inited. X-Git-Tag: 0.10~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ef5d49267aea61732cf8b3aceb3ecc10c04cc281;p=awesomized%2Flibmemcached Possible fix for problem where servaddr may not always be correctly inited. --- diff --git a/include/memcached.h b/include/memcached.h index f9ae2706..316f1f3f 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -110,6 +110,7 @@ struct memcached_server_st { char read_buffer[MEMCACHED_MAX_BUFFER]; size_t read_buffer_length; char *read_ptr; + memcached_allocated sockaddr_inited; struct sockaddr_in servAddr; memcached_connection type; uint8_t major_version; @@ -189,11 +190,11 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt time_t expiration); memcached_return memcached_increment(memcached_st *ptr, char *key, size_t key_length, - unsigned int offset, + uint32_t offset, uint64_t *value); memcached_return memcached_decrement(memcached_st *ptr, char *key, size_t key_length, - unsigned int offset, + uint32_t offset, uint64_t *value); void memcached_stat_free(memcached_st *, memcached_stat_st *); memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error); diff --git a/lib/memcached_auto.c b/lib/memcached_auto.c index f2ed0b8f..b9b74628 100644 --- a/lib/memcached_auto.c +++ b/lib/memcached_auto.c @@ -60,7 +60,7 @@ static memcached_return memcached_auto(memcached_st *ptr, memcached_return memcached_increment(memcached_st *ptr, char *key, size_t key_length, - unsigned int offset, + uint32_t offset, uint64_t *value) { memcached_return rc; @@ -74,7 +74,7 @@ memcached_return memcached_increment(memcached_st *ptr, memcached_return memcached_decrement(memcached_st *ptr, char *key, size_t key_length, - unsigned int offset, + uint32_t offset, uint64_t *value) { memcached_return rc; diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index cbf57fdc..0c256b71 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -72,13 +72,15 @@ static memcached_return udp_connect(memcached_st *ptr, unsigned int server_key) /* Old connection junk still is in the structure */ WATCHPOINT_ASSERT(ptr->hosts[server_key].stack_responses == 0); - if (ptr->hosts[server_key].servAddr.sin_family == 0) + if (ptr->hosts[server_key].sockaddr_inited == MEMCACHED_NOT_ALLOCATED) { memcached_return rc; rc= set_hostinfo(&ptr->hosts[server_key]); if (rc != MEMCACHED_SUCCESS) return rc; + + ptr->hosts[server_key].sockaddr_inited= MEMCACHED_ALLOCATED; } /* Create the socket */ diff --git a/tests/function.c b/tests/function.c index 837f14ff..68eddbd7 100644 --- a/tests/function.c +++ b/tests/function.c @@ -186,7 +186,7 @@ uint8_t append_binary_test(memcached_st *memc) assert((value_length == (sizeof(unsigned int) * x))); assert(rc == MEMCACHED_SUCCESS); - store_ptr= store_list; + store_ptr= (unsigned int *)value; x= 0; while (*store_ptr) {