Merge remote-tracking branch 'gh/next'

This commit is contained in:
Sage Weil 2014-06-05 12:03:00 -07:00
commit a63ee3793d
3 changed files with 14 additions and 6 deletions

View File

@ -122,7 +122,7 @@ namespace ceph {
#if SIZEOF_AO_T == 8
typedef atomic_t atomic64_t;
#else
typedef atomic_spinlock_t<long long> atomic64_t;
typedef atomic_spinlock_t<unsigned long long> atomic64_t;
#endif
}

View File

@ -2058,10 +2058,10 @@ extern "C" int rados_pool_list(rados_t cluster, char *buf, size_t len)
std::list<std::string>::const_iterator i = pools.begin();
std::list<std::string>::const_iterator p_end = pools.end();
for (; i != p_end; ++i) {
if (len == 0)
break;
int rl = i->length() + 1;
strncat(b, i->c_str(), len - 2); // leave space for two NULLs
if (len < (unsigned)rl)
break;
strncat(b, i->c_str(), rl);
needed += rl;
len -= rl;
b += rl;

View File

@ -8,8 +8,8 @@
#define POOL_LIST_BUF_SZ 32768
TEST(LibRadosPools, PoolList) {
std::vector<char> pool_list_buf(POOL_LIST_BUF_SZ, '\0');
char *buf = &pool_list_buf[0];
char pool_list_buf[POOL_LIST_BUF_SZ];
char *buf = pool_list_buf;
rados_t cluster;
std::string pool_name = get_temp_pool_name();
ASSERT_EQ("", create_one_pool(pool_name, &cluster));
@ -23,6 +23,14 @@ TEST(LibRadosPools, PoolList) {
buf += strlen(buf) + 1;
}
ASSERT_EQ(found_pool, true);
// make sure we honor the buffer size limit
buf = pool_list_buf;
memset(buf, 0, POOL_LIST_BUF_SZ);
ASSERT_LT(rados_pool_list(cluster, buf, 20), POOL_LIST_BUF_SZ);
ASSERT_NE(0, buf[0]); // include at least one pool name
ASSERT_EQ(0, buf[20]); // but don't touch the stopping point
ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}