Skip to content

Commit

Permalink
Merge pull request #32 from tallence/wip-da-fixes
Browse files Browse the repository at this point in the history
Some smaller fast fixes
  • Loading branch information
peter-mauritius committed Jun 2, 2017
2 parents 6e2c6ab + 46abeec commit 22b7dee
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/dict-rados/dict-rados.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,28 @@ class rados_dict_transaction_context {
}

ObjectWriteOperation &get_op(const std::string &key) {
if (key.find(DICT_PATH_SHARED) == 0) {
if (!key.compare(0, strlen(DICT_PATH_SHARED), DICT_PATH_SHARED)) {
dirty_shared |= true;
return write_op_shared;
} else if (key.find(DICT_PATH_PRIVATE) == 0) {
} else if (!key.compare(0, strlen(DICT_PATH_PRIVATE), DICT_PATH_PRIVATE)) {
dirty_private |= true;
return write_op_private;
}
i_unreached();
}

void set_locked(const std::string &key) {
if (key.find(DICT_PATH_SHARED) == 0) {
if (!key.compare(0, strlen(DICT_PATH_SHARED), DICT_PATH_SHARED)) {
locked_shared |= true;
} else if (key.find(DICT_PATH_PRIVATE) == 0) {
} else if (!key.compare(0, strlen(DICT_PATH_PRIVATE), DICT_PATH_PRIVATE)) {
locked_private |= true;
}
}

bool is_locked(const std::string &key) {
if (key.find(DICT_PATH_SHARED) == 0) {
if (!key.compare(0, strlen(DICT_PATH_SHARED), DICT_PATH_SHARED)) {
return locked_shared;
} else if (key.find(DICT_PATH_PRIVATE) == 0) {
} else if (!key.compare(0, strlen(DICT_PATH_PRIVATE), DICT_PATH_PRIVATE)) {
return locked_private;
}
i_unreached();
Expand Down Expand Up @@ -639,9 +639,9 @@ struct dict_iterate_context *rados_dict_iterate_init(struct dict *_dict, const c
set<string> shared_keys;
while (*paths) {
string key = *paths++;
if (key.find(DICT_PATH_SHARED) == 0) {
if (!key.compare(0, strlen(DICT_PATH_SHARED), DICT_PATH_SHARED)) {
shared_keys.insert(key);
} else if (key.find(DICT_PATH_PRIVATE) == 0) {
} else if (!key.compare(0, strlen(DICT_PATH_PRIVATE), DICT_PATH_PRIVATE)) {
private_keys.insert(key);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librmb/rados-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int RadosCluster::storage_create(const string &pool, const string &username, Rad
return err;
}
bool pool_found = false;
for (list<pair<int64_t, string>>::iterator it = pool_list.begin(); it != pool_list.end(); it++) {
for (list<pair<int64_t, string>>::iterator it = pool_list.begin(); it != pool_list.end(); ++it) {
if ((*it).second.compare(pool) == 0) {
pool_found = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/librmb/rados-dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ RadosDictionary::RadosDictionary(librados::IoCtx *ctx, const string &username, c
RadosDictionary::~RadosDictionary() { get_io_ctx().close(); }

const string RadosDictionary::get_full_oid(const std::string &key) {
if (key.find(DICT_PATH_SHARED) == 0) {
if (!key.compare(0, strlen(DICT_PATH_SHARED), DICT_PATH_SHARED)) {
return get_shared_oid();
} else if (key.find(DICT_PATH_PRIVATE) == 0) {
} else if (!key.compare(0, strlen(DICT_PATH_PRIVATE), DICT_PATH_PRIVATE)) {
return get_private_oid();
} else {
// TODO(peter) i_unreached();
Expand Down
12 changes: 6 additions & 6 deletions src/storage-rados/rados-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ using std::string;

class rados_save_context {
public:
explicit rados_save_context(RadosStorage &rados_storage) : rados_storage(rados_storage) {}
explicit rados_save_context(RadosStorage &rados_storage) : mbox(NULL), trans(NULL),
mail_count(0), sync_ctx(NULL),
seq(0), input(NULL),
rados_storage(rados_storage),
mailObject(NULL), failed(1),
finished(1) {}

struct mail_save_context ctx;

Expand Down Expand Up @@ -317,11 +322,6 @@ int rados_transaction_save_commit_pre(struct mail_save_context *_ctx) {
struct mailbox_transaction_context *_t = _ctx->transaction;
const struct mail_index_header *hdr;
struct seq_range_iter iter;
uint32_t uid;
const char *dir;
string_t *src_path, *dest_path;
unsigned int n;
size_t src_prefixlen, dest_prefixlen;

i_assert(ctx->finished);

Expand Down
1 change: 0 additions & 1 deletion src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ static int rbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) {
FUNC_START();
struct dbox_mail *mail = (struct dbox_mail *)_mail;
struct index_mail_data *data = &mail->imail.data;
struct dbox_file *file;
struct rbox_storage *rbox_storage = (struct rbox_storage *)_mail->box->storage;

uint64_t file_size;
Expand Down
6 changes: 3 additions & 3 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ off_t stream_mail_to_rados(const struct rbox_storage *storage, const std::string
bl.clear();
bl.append((const char *)data);

int err = ((storage->s)->get_io_ctx()).write(oid, bl, iov.iov_len, offset);
if (err < 0) {
ret = ((storage->s)->get_io_ctx()).write(oid, bl, iov.iov_len, offset);
if (ret < 0) {
return -1;
}
i_stream_skip(instream, 0);
Expand Down Expand Up @@ -387,7 +387,7 @@ static int rbox_save_mail_write_metadata(struct dbox_save_context *ctx, struct d
}

static void remove_from_rados(librmb::RadosStorage *storage, char *oid) {
if (oid != 0 && storage != 0 && storage != 0) {
if (oid != 0 && storage != 0) {
i_debug("object to delete is : %s", oid);
(storage->get_io_ctx()).remove(oid);
}
Expand Down

0 comments on commit 22b7dee

Please sign in to comment.