mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
modules/media: Hold a reference to magick module.
This commit is contained in:
parent
3121dc30df
commit
6d4e17a77c
4 changed files with 52 additions and 29 deletions
|
@ -323,7 +323,7 @@ ircd::m::module_names
|
|||
decltype(ircd::m::module_names_optional)
|
||||
ircd::m::module_names_optional
|
||||
{
|
||||
"media_magick",
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -10,35 +10,52 @@
|
|||
|
||||
#include "media.h"
|
||||
|
||||
mapi::header
|
||||
ircd::mapi::header
|
||||
IRCD_MODULE
|
||||
{
|
||||
"11.7 :Content respository",
|
||||
[] // init
|
||||
{
|
||||
static const std::string dbopts;
|
||||
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
|
||||
{
|
||||
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>{};
|
||||
}
|
||||
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"};
|
||||
|
||||
// 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");
|
||||
|
||||
try
|
||||
{
|
||||
::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>{};
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue