#define MEMCACHED_MAX_HOST_LENGTH 64
#define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */
#define MEMCACHED_WHEEL_SIZE 1024
-#define MEMCACHED_CONTINUUM_SIZE 2048
#define MEMCACHED_POINTS_PER_SERVER 100
+#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */
#define MEMCACHED_STRIDE 4
#define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX
{
struct continuum_item *ct1 = (struct continuum_item *)t1;
struct continuum_item *ct2 = (struct continuum_item *)t2;
- if(ct1->value == ct2->value)
+
+ WATCHPOINT_ASSERT(ct1->value != 153);
+ if (ct1->value == ct2->value)
return 0;
- else if(ct1->value > ct2->value)
+ else if (ct1->value > ct2->value)
return 1;
else
return -1;
void update_continuum(memcached_st *ptr)
{
- int index;
- int host_index;
- int continuum_index= 0;
- int value;
+ uint32_t index;
+ uint32_t host_index;
+ uint32_t continuum_index= 0;
+ uint32_t value;
memcached_server_st *list = ptr->hosts;
for (host_index = 0; host_index < ptr->number_of_hosts; ++host_index)
}
}
+ WATCHPOINT_ASSERT(ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER <= MEMCACHED_CONTINUUM_SIZE);
qsort(ptr->continuum, ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER, sizeof(struct continuum_item), continuum_item_cmp);
#ifdef HAVE_DEBUG
- for(index= 0; index < ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER - 1; ++index)
+ for (index= 0; index < ((ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER) - 1); index++)
{
- WATCHPOINT_ASSERT(ptr->continuum[index].value < ptr->continuum[index + 1].value);
+ WATCHPOINT_ASSERT(ptr->continuum[index].value <= ptr->continuum[index + 1].value);
}
#endif
}
unsigned int server_key;
WATCHPOINT_ASSERT(!(value == NULL && value_length > 0));
- WATCHPOINT_ASSERT(!(value && value_length == 0));
unlikely (key_length == 0)
return MEMCACHED_NO_KEY_PROVIDED;
#define WATCHPOINT_STRING_LENGTH(A,B) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout);
#define WATCHPOINT_NUMBER(A) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout);
#define WATCHPOINT_ERRNO(A) fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout);
+#define WATCHPOINT_ASSERT_PRINT(A,B,C) if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout);}assert((A));
#define WATCHPOINT_ASSERT(A) assert((A));
#else
#define WATCHPOINT
#define WATCHPOINT_STRING(A)
#define WATCHPOINT_NUMBER(A)
#define WATCHPOINT_ERRNO(A)
+#define WATCHPOINT_ASSERT_PRINT(A,B,C)
#define WATCHPOINT_ASSERT(A)
#endif
#endif /* MEMCACHED_INTERNAL */