Browse Source

cache release function

ENGINE-781
Volker Birk 5 years ago
parent
commit
f6092c8427
  1. 10
      message_cache.cc
  2. 4
      message_cache.hh
  3. 4
      test/test_message_cache.cc

10
message_cache.cc

@ -16,7 +16,7 @@ namespace pEp {
rating, flags); rating, flags);
} }
PEP_STATUS MessageCache::cached_mime_encode_message( PEP_STATUS MessageCache::cache_mime_encode_message(
which one, which one,
const message * msg, const message * msg,
bool omit_fields, bool omit_fields,
@ -28,6 +28,14 @@ namespace pEp {
mimetext, has_pEp_msg_attachment); mimetext, has_pEp_msg_attachment);
} }
void MessageCache::cache_release(std::string id)
{
try {
message_cache._cache.erase(id);
}
catch (...) { }
}
static char *dup(const char *src) static char *dup(const char *src)
{ {
if (!src) if (!src)

4
message_cache.hh

@ -33,7 +33,7 @@ namespace pEp {
enum which { msg_src, msg_dst };; enum which { msg_src, msg_dst };;
static PEP_STATUS cached_mime_encode_message( static PEP_STATUS cache_mime_encode_message(
which one, which one,
const message * msg, const message * msg,
bool omit_fields, bool omit_fields,
@ -41,6 +41,8 @@ namespace pEp {
bool has_pEp_msg_attachment bool has_pEp_msg_attachment
); );
static void cache_release(std::string id);
protected: protected:
DYNAMIC_API PEP_STATUS decrypt_message( DYNAMIC_API PEP_STATUS decrypt_message(
PEP_SESSION session, PEP_SESSION session,

4
test/test_message_cache.cc

@ -33,6 +33,8 @@ int main()
src->attachments = new_bloblist(strdup("blobdata"), 8, "application/octet-stream", "blob.data"); src->attachments = new_bloblist(strdup("blobdata"), 8, "application/octet-stream", "blob.data");
assert(src->attachments && src->attachments->value); assert(src->attachments && src->attachments->value);
// add to cache
::message *dst = nullptr; ::message *dst = nullptr;
PEP_rating rating; PEP_rating rating;
PEP_decrypt_flags_t flags = 0; PEP_decrypt_flags_t flags = 0;
@ -49,6 +51,8 @@ int main()
assert(string(src->longmsg) == "pEp"); assert(string(src->longmsg) == "pEp");
assert(src->attachments == nullptr); assert(src->attachments == nullptr);
// remove from cache
cout << status << endl; cout << status << endl;
::free_message(src); ::free_message(src);

Loading…
Cancel
Save