Skip to content

Commit

Permalink
flat allocator broken by my last change
Browse files Browse the repository at this point in the history
Summary: oops, i'm dumb.

Reviewed By: ps

Test Plan: compiled.

Revert: OK


git-svn-id: http://svn.facebook.com/svnroot/projects/memcached/trunk@122293 2c7ba8d8-a2f7-0310-a573-de162e16dcc7
  • Loading branch information
ttung committed Sep 18, 2008
1 parent c0dbcaf commit b04e15b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 36 deletions.
2 changes: 1 addition & 1 deletion conn_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static struct {
} l;


STATIC int cb_freelist_check(conn_buffer_group_t* cbg) {
CB_STATIC int cb_freelist_check(conn_buffer_group_t* cbg) {
#if defined(FREELIST_CHECK)
size_t i, found_entries, rsize_total;
bool end_found = false;
Expand Down
21 changes: 7 additions & 14 deletions conn_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#define _conn_buffer_h_

#if defined(CONN_BUFFER_TESTS)
#define STATIC
#define CB_STATIC
#if defined(CONN_BUFFER_MODULE)
#define STATIC_DECL(decl) decl
#define CB_STATIC_DECL(decl) decl
#else
#define STATIC_DECL(decl) extern decl
#define CB_STATIC_DECL(decl) extern decl
#endif /* #if defined(CONN_BUFFER_MODULE) */

#else
#define STATIC static
#define CB_STATIC static
#if defined(CONN_BUFFER_MODULE)
#define STATIC_DECL(decl) static decl
#define CB_STATIC_DECL(decl) static decl
#else
#define STATIC_DECL(decl)
#define CB_STATIC_DECL(decl)
#endif /* #if defined(CONN_BUFFER_MODULE) */
#endif /* #if defined(CONN_BUFFER_TESTS) */

Expand Down Expand Up @@ -113,13 +113,6 @@ extern void conn_buffer_init(unsigned threads,
extern conn_buffer_group_t* get_conn_buffer_group(unsigned thread);
extern bool assign_thread_id_to_conn_buffer_group(unsigned group, pthread_t tid);

STATIC_DECL(int cb_freelist_check(conn_buffer_group_t* cbg));

#if !defined(CONN_BUFFER_MODULE)
#undef STATIC
#undef STATIC_DECL
#else
#undef CONN_BUFFER_MODULE
#endif /* #if !defined(CONN_BUFFER_MODULE) */
CB_STATIC_DECL(int cb_freelist_check(conn_buffer_group_t* cbg));

#endif /* #if !defined(_conn_buffer_h_) */
4 changes: 2 additions & 2 deletions flat_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void item_init(void) {

/* initialize at least nbytes more memory and add them as large chunks to the
* free list. */
STATIC bool flat_storage_alloc(void) {
FA_STATIC bool flat_storage_alloc(void) {
large_chunk_t* initialize_end;

if (FLAT_STORAGE_INCREMENT_DELTA > fsi.unused_memory) {
Expand Down Expand Up @@ -392,7 +392,7 @@ static void unbreak_large_chunk(large_chunk_t* lc, bool mandatory) {
/*
* gets the oldest item on the LRU with refcount == 0.
*/
STATIC item* get_lru_item(void) {
FA_STATIC item* get_lru_item(void) {
int i;
item* iter, * prev;

Expand Down
23 changes: 8 additions & 15 deletions flat_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@
#endif

#if defined(FLAT_STORAGE_TESTS)
#define STATIC
#define FA_STATIC
#if defined(FLAT_STORAGE_MODULE)
#define STATIC_DECL(decl) decl
#define FA_STATIC_DECL(decl) decl
#else
#define STATIC_DECL(decl) extern decl
#define FA_STATIC_DECL(decl) extern decl
#endif /* #if defined(FLAT_STORAGE_MODULE) */

#else
#define STATIC static
#define FA_STATIC static
#if defined(FLAT_STORAGE_MODULE)
#define STATIC_DECL(decl) static decl
#define FA_STATIC_DECL(decl) static decl
#else
#define STATIC_DECL(decl)
#define FA_STATIC_DECL(decl)
#endif /* #if defined(FLAT_STORAGE_MODULE) */
#endif /* #if defined(FLAT_STORAGE_TESTS) */

Expand Down Expand Up @@ -677,15 +677,8 @@ extern const char* item_key_copy(const item* it, char* keyptr);

DECL_MT_FUNC(char*, flat_allocator_stats, (size_t* bytes));

STATIC_DECL(bool flat_storage_alloc(void));
STATIC_DECL(item* get_lru_item(void));

#if !defined(FLAT_STORAGE_MODULE)
#undef STATIC
#undef STATIC_DECL
#else
#undef FLAT_STORAGE_MODULE
#endif /* #if !defined(FLAT_STORAGE_MODULE) */
FA_STATIC_DECL(bool flat_storage_alloc(void));
FA_STATIC_DECL(item* get_lru_item(void));


static inline size_t __fs_MIN(size_t a, size_t b) {
Expand Down
4 changes: 2 additions & 2 deletions flat_storage_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ static inline size_t item_setup_receive(item* it, conn* c) {

assert(c->riov == NULL);
assert(c->riov_size == 0);
c->riov = (struct iovec*) alloc_conn_buffer(sizeof(struct iovec) * iov_len_required);
c->riov = (struct iovec*) alloc_conn_buffer(c->cbg, sizeof(struct iovec) * iov_len_required);
if (c->riov == NULL) {
return false;
}
}
/* in binary protocol, receiving the key already requires the riov to be set
* up. */

report_max_rusage(c->riov, sizeof(struct iovec) * iov_len_required);
report_max_rusage(c->cbg, c->riov, sizeof(struct iovec) * iov_len_required);
c->riov_size = iov_len_required;
c->riov_left = iov_len_required;
c->riov_curr = 0;
Expand Down
1 change: 0 additions & 1 deletion memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ int mt_store_item(item *item, int comm, const char* key);
# define conn_from_freelist mt_conn_from_freelist
# define conn_add_to_freelist mt_conn_add_to_freelist
# define defer_delete mt_defer_delete
# define flat_allocator_stats mt_flat_allocator_stats
# define is_listen_thread mt_is_listen_thread
# define item_alloc mt_item_alloc
# define item_cachedump mt_item_cachedump
Expand Down
2 changes: 1 addition & 1 deletion thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void mt_slabs_rebalance() {

#if defined(USE_FLAT_ALLOCATOR)
/******************************* FLAT ALLOCATOR ******************************/
char* mt_flat_allocator_stats(size_t* result_size) {
char* flat_allocator_stats(size_t* result_size) {
char* ret;

pthread_mutex_lock(&cache_lock);
Expand Down

0 comments on commit b04e15b

Please sign in to comment.