Skip to content

Commit

Permalink
Merge pull request #59 from tallence/wip-da-sca-20170721
Browse files Browse the repository at this point in the history
Fix some smaller code issues
  • Loading branch information
pburow authored Jul 24, 2017
2 parents 9e014b0 + d9edb39 commit d49354b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ To compile the plugin you need a configured or installed dovecot.
./configure --with-dovecot=/home/user/workspace/core
make install

### Under (open)SUSE install dovecot, then

./autogen.sh
export CXXFLAGS='-O2 -fPIC -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -I/usr/lib64'
./configure --prefix=/usr --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib --with-dovecot=/usr/lib64/dovecot
cd src/librmb
make
sudo make install
cd ../..
make
sudo make install

## Thanks

<table border="0">
Expand Down
8 changes: 4 additions & 4 deletions src/dict-rados/dict-rados.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,20 @@ class rados_dict_transaction_context {

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

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

Expand Down
10 changes: 10 additions & 0 deletions src/dict-rados/test-dict-rados.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,17 @@ int main(int argc, const char *argv[]) {
}
}
ret = rados_conf_parse_env(rados, NULL);
if (ret < 0) {
printf("couldn't configure cluster handle! error %d\n", ret);
ret = EXIT_FAILURE;
goto out;
}
ret = rados_conf_read_file(rados, NULL);
if (ret < 0) {
printf("couldn't read config file! error %d\n", ret);
ret = EXIT_FAILURE;
goto out;
}

/*
* Now we need to get the rados object its config info. It can
Expand Down
42 changes: 19 additions & 23 deletions src/librmb/rados-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,33 @@ RadosCluster::~RadosCluster() {}

int RadosCluster::init(string *error_r) {
const char *const *args;
int ret = 0;

if (cluster_ref_count == 0) {
if (ret >= 0) {
ret = cluster.init(nullptr);
if (ret < 0) {
*error_r = "Couldn't create the cluster handle! " + string(strerror(-ret));
}
int ret = 0;
ret = cluster.init(nullptr);
if (ret < 0) {
*error_r = "Couldn't create the cluster handle! " + string(strerror(-ret));
return ret;
}

if (ret >= 0) {
ret = cluster.conf_parse_env(nullptr);
if (ret < 0) {
*error_r = "Cannot parse config environment! " + string(strerror(-ret));
}
ret = cluster.conf_parse_env(nullptr);
if (ret < 0) {
*error_r = "Cannot parse config environment! " + string(strerror(-ret));
return ret;
}

if (ret >= 0) {
ret = cluster.conf_read_file(nullptr);
if (ret < 0) {
*error_r = "Cannot read config file! " + string(strerror(-ret));
}
ret = cluster.conf_read_file(nullptr);
if (ret < 0) {
*error_r = "Cannot read config file! " + string(strerror(-ret));
return ret;
}

if (ret >= 0) {
ret = cluster.connect();
if (ret < 0) {
*error_r = "Cannot connect to cluster! " + string(strerror(-ret));
} else {
cluster_ref_count++;
}
ret = cluster.connect();
if (ret < 0) {
*error_r = "Cannot connect to cluster! " + string(strerror(-ret));
return ret;
} else {
cluster_ref_count++;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int rbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, s
struct istream *input;

struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
unsigned int ret = 0;
int ret = 0;

i_debug("rbox_mail_get_stream(oid=%s, uid=%d):", rmail->mail_object->get_oid().c_str(), _mail->uid);

Expand Down Expand Up @@ -256,7 +256,7 @@ static int rbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, s
break;
}

mail_data_bl.copy(0, ret, &rmail->mail_buffer[0]);
mail_data_bl.copy(0, (unsigned)ret, &rmail->mail_buffer[0]);
i_debug("rbox_mail_get_stream(oid=%s, size_r = %lu, read_from_rados = %d):",
rmail->mail_object->get_oid().c_str(), size_r, ret);

Expand Down
7 changes: 1 addition & 6 deletions src/storage-rbox/rbox-save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ bool wait_for_rados_operations(std::vector<librmb::RadosMailObject *> &object_li
if ((*it_cur_obj)->has_active_op()) {
for (std::map<librados::AioCompletion *, librados::ObjectWriteOperation *>::iterator map_it =
(*it_cur_obj)->get_completion_op_map()->begin();
map_it != (*it_cur_obj)->get_completion_op_map()->end(); map_it++) {
map_it != (*it_cur_obj)->get_completion_op_map()->end(); ++map_it) {
map_it->first->wait_for_complete_and_cb();
ctx_failed = map_it->first->get_return_value() < 0 || ctx_failed ? true : false;
// clean up
Expand Down Expand Up @@ -401,11 +401,6 @@ int rbox_transaction_save_commit_pre(struct mail_save_context *_ctx) {

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;
struct rbox_storage *r_storage = (struct rbox_storage *)&r_ctx->mbox->storage->storage;

i_assert(r_ctx->finished);
Expand Down
5 changes: 3 additions & 2 deletions src/storage-rbox/rbox-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern "C" {
static int rbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx, const char *path, bool primary) {
struct mail_storage *storage = ctx->box->storage;
DIR *dir;
struct dirent *d;
int ret = 0;

dir = opendir(path);
Expand All @@ -37,7 +36,9 @@ static int rbox_sync_index_rebuild_dir(struct index_rebuild_context *ctx, const
}
/*TODO(jrse) do we need to copy files?
*
* do {
*
struct dirent *d;
do {
errno = 0;
if ((d = readdir(dir)) == NULL)
break;
Expand Down

0 comments on commit d49354b

Please sign in to comment.