Skip to content

Commit

Permalink
Develop (#285)
Browse files Browse the repository at this point in the history
* 217: fix unused code.

* 217: unused code and warning

* disabled man pages for rmb

* Bugfix/283 virtual mailbox fetch metadata (#284)

* Develop (#282)

* 217: fix unused code.

* 217: unused code and warning

* disabled man pages for rmb

* #283: fetch metadata for mails in virtual mailbox

* #283: fix metadata date.saved. date.received virtual mailbox

* #283: version
  • Loading branch information
jrse committed Feb 23, 2022
1 parent a0d29ec commit 1171370
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .travis.yml_old → .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ language: cpp
services:
- docker
env:
- DOVECOT="release-2.2.21"
- DOVECOT="master-2.3"
- DOVECOT="master-2.2"
before_install:
- docker volume create --name ceph_config
- docker network create --driver=bridge --subnet=192.168.100.0/24 --gateway=192.168.100.1 ceph_network
- travis_wait 30 docker run -d --net=ceph_network --name ceph_demo --mount type=tmpfs,destination=/etc/ceph -v ceph_config:/root/cfg -e MON_IP=192.168.100.2 -e CEPH_PUBLIC_NETWORK=192.168.100.0/24 -e CEPH_DEMO_UID=$DOVECOT ceph/daemon:latest demo

- travis_wait 30 docker run -itd --name build --net=ceph_network -e SOURCE_VERSION=$DOVECOT -v ceph_config:/etc/ceph -v $(pwd):/repo cephdovecot/travis-build-$DOVECOT:latest sh
- docker exec build sh -c 'printf "nameserver 8.8.8.8\n" > /etc/resolv.conf'
- docker exec build apt-get -qq update
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [0.0.25](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.25) (2022-02-23)

- virtual_mailbox: bugfix fetch fields (x-guid, date.saved..)

## [0.0.24](https://github.com/ceph-dovecot/dovecot-ceph-plugin/tree/0.0.24) (2022-02-07)

- list namespace object only once, in case of force-resync
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

AC_PREREQ([2.59])

AC_INIT([dovecot-ceph-plugin], [0.0.24], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_INIT([dovecot-ceph-plugin], [0.0.25], [https://github.com/ceph-dovecot/dovecot-ceph-plugin/issues/new], ,[https://github.com/ceph-dovecot/dovecot-ceph-plugin])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion rpm/dovecot-ceph-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Name: dovecot-ceph-plugin
Summary: Dovecot Ceph RADOS plugins
Version: 0.0.24
Version: 0.0.25
Release: 0%{?dist}
URL: https://github.com/ceph-dovecot/dovecot-ceph-plugin
Group: Productivity/Networking/Email/Servers
Expand Down
4 changes: 2 additions & 2 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ static int iterate_mailbox(const struct mail_namespace *ns, const struct mailbox
[oid](librmb::RadosMail *m) { return m->get_oid()->compare(oid) == 0; });

if (it_mail == mail_objects.end()) {
//std::cout << " missing mail object: uid=" << mail->uid << " guid=" << guid << " oid : " << oid
// << " available: " << (it_mail != mail_objects.end()) << std::endl;
std::cout << " missing mail object: uid=" << mail->uid << " guid=" << guid << " oid : " << oid
<< " available: " << (it_mail != mail_objects.end()) << std::endl;

++mail_count_missing;
} else {
Expand Down
49 changes: 43 additions & 6 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,36 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
FUNC_END();
return -1;
}

// update metadata storage io_ctx and load metadata
if (alt_storage) {
r_storage->ms->get_storage()->set_io_ctx(&r_storage->alt->get_io_ctx());
} else {
r_storage->ms->get_storage()->set_io_ctx(&r_storage->s->get_io_ctx());
}

/*#283: virtual mailbox needs this (different initialisation path)*/
if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(mail) < 0) {
i_error("Error rbox_get_index_record uid(%d)", mail->uid);
FUNC_END();
return -1;
}
}

int ret_load_metadata = r_storage->ms->get_storage()->load_metadata(rmail->rados_mail);
if (ret_load_metadata < 0) {
std::string metadata_key = librmb::rbox_metadata_key_to_char(key);
if (ret_load_metadata == -ENOENT) {
i_warning("Errorcode: %d cannot get x_attr(%s,%c) from object %s, process %d", ret_load_metadata,
metadata_key.c_str(), key, rmail->rados_mail->get_oid()->c_str(), getpid());
rbox_mail_set_expunged(rmail);
} else {
} else {
i_error("Errorcode: %d cannot get x_attr(%s,%c) from object %s, process %d", ret_load_metadata,
metadata_key.c_str(), key, rmail->rados_mail->get_oid()->c_str(), getpid());
metadata_key.c_str(), key, rmail->rados_mail != NULL ? rmail->rados_mail->get_oid()->c_str() : " no oid", getpid());
}
FUNC_END();
return -1;
Expand Down Expand Up @@ -164,6 +176,17 @@ static int rbox_mail_get_received_date(struct mail *_mail, time_t *date_r) {
// in case we already read the metadata this gives us the value
// void get_metadata(rbox_metadata_key key, std::string* value) {

if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
return -1;
}
}
librmb::RadosUtils::get_metadata(rbox_metadata_key::RBOX_METADATA_RECEIVED_TIME, rmail->rados_mail->get_metadata(),
&value);

Expand Down Expand Up @@ -223,6 +246,19 @@ static int rbox_mail_get_save_date(struct mail *_mail, time_t *date_r) {
FUNC_END_RET("ret == 0");
return 0;
}

if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
struct rbox_storage *r_storage = (struct rbox_storage *)_mail->box->storage;
rmail->rados_mail = r_storage->s->alloc_rados_mail();
if (rbox_get_index_record(_mail) < 0) {
i_error("Error rbox_get_index uid(%d)", _mail->uid);
FUNC_END();
return -1;
}
}

if (rmail->rados_mail->get_rados_save_date() != -1) {
*date_r = data->save_date = rmail->rados_mail->get_rados_save_date();
return 0;
Expand Down Expand Up @@ -391,19 +427,20 @@ static int rbox_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED, s
int ret = -1;
enum mail_flags flags = index_mail_get_flags(_mail);
bool alt_storage = is_alternate_storage_set(flags) && is_alternate_pool_valid(_mail->box);

if (data->stream == NULL) {
if (rbox_open_rados_connection(_mail->box, alt_storage) < 0) {
FUNC_END_RET("ret == -1; connection to rados failed");
return -1;
}

librmb::RadosStorage *rados_storage = alt_storage ? ((struct rbox_storage *)_mail->box->storage)->alt
: ((struct rbox_storage *)_mail->box->storage)->s;
if (alt_storage) {
rados_storage->set_namespace(rados_storage->get_namespace());
}

/* Pop3 needs this. it looks like rbox_index_mail_set_seq is not called. */
/* Pop3 and virtual box needs this. it looks like rbox_index_mail_set_seq is not called. */
if (rmail->rados_mail == nullptr) {
// make sure that mail_object is initialized,
// else create and load guid from index.
Expand Down Expand Up @@ -605,7 +642,7 @@ static int rbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field
if (ret == 0) {
index_pop3_uidl_update_exists(&mail->imail.mail.mail, (*value_r)[0] != '\0');
}
#endif
#endif
return ret;
case MAIL_FETCH_POP3_ORDER:
if (!rbox_header_have_flag(_mail->box, mbox->hdr_ext_id, offsetof(struct rbox_index_header, flags),
Expand Down

0 comments on commit 1171370

Please sign in to comment.