0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 04:38:52 +02:00

modules/media: Hold a reference to magick module.

This commit is contained in:
Jason Volk 2019-07-25 21:09:43 -07:00
parent 3121dc30df
commit 6d4e17a77c
4 changed files with 52 additions and 29 deletions

View file

@ -323,7 +323,7 @@ ircd::m::module_names
decltype(ircd::m::module_names_optional)
ircd::m::module_names_optional
{
"media_magick",
};
///////////////////////////////////////////////////////////////////////////////

View file

@ -10,34 +10,51 @@
#include "media.h"
mapi::header
ircd::mapi::header
IRCD_MODULE
{
"11.7 :Content respository",
[] // init
{
ircd::m::media::init,
ircd::m::media::fini
};
void
ircd::m::media::init()
{
static const std::string dbopts;
media = std::make_shared<database>("media", dbopts, media_description);
blocks = db::column{*media, "blocks"};
::media = std::make_shared<database>("media", dbopts, media_description);
::blocks = db::column{*::media, "blocks"};
// The conf setter callbacks must be manually executed after
// the database was just loaded to set the cache size.
conf::reset("ircd.media.blocks.cache.size");
conf::reset("ircd.media.blocks.cache_comp.size");
magick_support.reset(new module{"magick"});
},
[] // fini
try
{
magick_support.reset();
::magick_support.reset(new module{"magick"});
}
catch(std::exception &e)
{
log::warning
{
media_log, "Failed to load GraphicsMagick support :%s",
e.what()
};
}
}
void
ircd::m::media::fini()
{
::magick_support.reset();
// The database close contains pthread_join()'s within RocksDB which
// deadlock under certain conditions when called during a dlclose()
// (i.e static destruction of this module). Therefor we must manually
// close the db here first.
media = std::shared_ptr<database>{};
}
};
::media = std::shared_ptr<database>{};
}
decltype(media_log)
media_log
@ -149,8 +166,8 @@ media;
decltype(blocks)
blocks;
decltype(magick)
magick;
decltype(magick_support)
magick_support;
std::set<m::room::id>
downloading;

View file

@ -8,6 +8,12 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
namespace ircd::m::media
{
void init();
void fini();
}
using namespace ircd;
extern mapi::header IRCD_MODULE;

View file

@ -252,9 +252,9 @@ get__thumbnail_local(client &client,
copied
};
static const bool available
const bool available
{
mods::loaded("media_magick")
magick_support
};
const auto mime_type