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)
|
decltype(ircd::m::module_names_optional)
|
||||||
ircd::m::module_names_optional
|
ircd::m::module_names_optional
|
||||||
{
|
{
|
||||||
"media_magick",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -10,34 +10,51 @@
|
||||||
|
|
||||||
#include "media.h"
|
#include "media.h"
|
||||||
|
|
||||||
mapi::header
|
ircd::mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
"11.7 :Content respository",
|
"11.7 :Content respository",
|
||||||
[] // init
|
ircd::m::media::init,
|
||||||
|
ircd::m::media::fini
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::m::media::init()
|
||||||
{
|
{
|
||||||
static const std::string dbopts;
|
static const std::string dbopts;
|
||||||
media = std::make_shared<database>("media", dbopts, media_description);
|
::media = std::make_shared<database>("media", dbopts, media_description);
|
||||||
blocks = db::column{*media, "blocks"};
|
::blocks = db::column{*::media, "blocks"};
|
||||||
|
|
||||||
// The conf setter callbacks must be manually executed after
|
// The conf setter callbacks must be manually executed after
|
||||||
// the database was just loaded to set the cache size.
|
// the database was just loaded to set the cache size.
|
||||||
conf::reset("ircd.media.blocks.cache.size");
|
conf::reset("ircd.media.blocks.cache.size");
|
||||||
conf::reset("ircd.media.blocks.cache_comp.size");
|
conf::reset("ircd.media.blocks.cache_comp.size");
|
||||||
|
|
||||||
magick_support.reset(new module{"magick"});
|
try
|
||||||
},
|
|
||||||
[] // fini
|
|
||||||
{
|
{
|
||||||
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
|
// The database close contains pthread_join()'s within RocksDB which
|
||||||
// deadlock under certain conditions when called during a dlclose()
|
// deadlock under certain conditions when called during a dlclose()
|
||||||
// (i.e static destruction of this module). Therefor we must manually
|
// (i.e static destruction of this module). Therefor we must manually
|
||||||
// close the db here first.
|
// close the db here first.
|
||||||
media = std::shared_ptr<database>{};
|
::media = std::shared_ptr<database>{};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
decltype(media_log)
|
decltype(media_log)
|
||||||
media_log
|
media_log
|
||||||
|
@ -149,8 +166,8 @@ media;
|
||||||
decltype(blocks)
|
decltype(blocks)
|
||||||
blocks;
|
blocks;
|
||||||
|
|
||||||
decltype(magick)
|
decltype(magick_support)
|
||||||
magick;
|
magick_support;
|
||||||
|
|
||||||
std::set<m::room::id>
|
std::set<m::room::id>
|
||||||
downloading;
|
downloading;
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
|
namespace ircd::m::media
|
||||||
|
{
|
||||||
|
void init();
|
||||||
|
void fini();
|
||||||
|
}
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
extern mapi::header IRCD_MODULE;
|
extern mapi::header IRCD_MODULE;
|
||||||
|
|
|
@ -252,9 +252,9 @@ get__thumbnail_local(client &client,
|
||||||
copied
|
copied
|
||||||
};
|
};
|
||||||
|
|
||||||
static const bool available
|
const bool available
|
||||||
{
|
{
|
||||||
mods::loaded("media_magick")
|
magick_support
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto mime_type
|
const auto mime_type
|
||||||
|
|
Loading…
Reference in a new issue