# HG changeset patch # User David Demelier # Date 1530946585 -7200 # Node ID 48afa8c41f501328e686e303be9635864cfca8f7 # Parent bd7feaa002cb6c999216c7b912119fe36fbfe250 Irccd: verify dynlib_plugin major version too While here, fix the dynlib_plugin test that was not updated at that time. diff -r bd7feaa002cb -r 48afa8c41f50 cmake/internal/sysconfig.hpp.in --- a/cmake/internal/sysconfig.hpp.in Fri Jul 06 19:32:54 2018 +0200 +++ b/cmake/internal/sysconfig.hpp.in Sat Jul 07 08:56:25 2018 +0200 @@ -93,4 +93,14 @@ #cmakedefine HAVE_STD_PUT_TIME #cmakedefine HAVE_SYSLOG +/** + * \brief Describe irccd version. + */ +struct version { + unsigned major{IRCCD_VERSION_MAJOR}; //!< major + unsigned minor{IRCCD_VERSION_MINOR}; //!< minor + unsigned patch{IRCCD_VERSION_PATCH}; //!< patch + unsigned abi{IRCCD_VERSION_SHLIB}; //!< ABI compatibility +}; + #endif // !IRCCD_SYSCONFIG_HPP diff -r bd7feaa002cb -r 48afa8c41f50 libirccd/irccd/daemon/dynlib_plugin.cpp --- a/libirccd/irccd/daemon/dynlib_plugin.cpp Fri Jul 06 19:32:54 2018 +0200 +++ b/libirccd/irccd/daemon/dynlib_plugin.cpp Sat Jul 07 08:56:25 2018 +0200 @@ -70,13 +70,16 @@ { const auto [ abisym, initsym ] = symbol(path); - using abisym_func_type = unsigned (); + using abisym_func_type = version (); using initsym_func_type = std::unique_ptr (); const auto abi = boost::dll::import(path, abisym); const auto init = boost::dll::import(path, initsym); - if (abi() != IRCCD_VERSION_SHLIB) + // The abi version is reset after new major version, check for both. + const version current; + + if (current.major != abi().major || current.abi != abi().abi) throw plugin_error(plugin_error::exec_error, id, "incompatible version"); auto plg = init(); diff -r bd7feaa002cb -r 48afa8c41f50 plugins/links/links.cpp --- a/plugins/links/links.cpp Fri Jul 06 19:32:54 2018 +0200 +++ b/plugins/links/links.cpp Sat Jul 07 08:56:25 2018 +0200 @@ -427,9 +427,9 @@ extern "C" { BOOST_SYMBOL_EXPORT -auto irccd_abi_links() -> unsigned +auto irccd_abi_links() -> version { - return IRCCD_VERSION_SHLIB; + return version(); } BOOST_SYMBOL_EXPORT diff -r bd7feaa002cb -r 48afa8c41f50 tests/src/libirccd/dynlib-plugin/test_plugin.cpp --- a/tests/src/libirccd/dynlib-plugin/test_plugin.cpp Fri Jul 06 19:32:54 2018 +0200 +++ b/tests/src/libirccd/dynlib-plugin/test_plugin.cpp Sat Jul 07 08:56:25 2018 +0200 @@ -120,8 +120,20 @@ } }; -extern "C" BOOST_SYMBOL_EXPORT test_plugin irccd_plugin_test_plugin; +extern "C" { + +BOOST_SYMBOL_EXPORT +auto irccd_abi_test_plugin() -> version +{ + return version(); +} -test_plugin irccd_plugin_test_plugin("test", ""); +BOOST_SYMBOL_EXPORT +auto irccd_init_test_plugin() -> std::unique_ptr +{ + return std::make_unique("testplugin", ""); +} + +} // !C } // !irccd