@ -98,6 +98,21 @@ void Plugin::SetSessionManager(SessionManager * psession_manager)
void Plugin : : Lock ( )
{
if ( synchro )
synchro - > Lock ( ) ;
}
void Plugin : : Unlock ( )
{
if ( synchro )
synchro - > Unlock ( ) ;
}
bool Plugin : : SetPointers ( PluginInfo & info )
{
@ -105,7 +120,11 @@ bool Plugin::SetPointers(PluginInfo & info)
bool res = ( db & & config & & cur & & system & & functions & & templates & & synchro & & session_manager ) ;
if ( ! res )
{
Lock ( ) ;
log < < log1 < < " Plugin: cannot call a function - some of the winix pointers are null " < < logend ;
Unlock ( ) ;
}
info . db = db ;
info . config = config ;
@ -145,7 +164,8 @@ void Plugin::LoadPlugin(const std::string & filename)
}
// we don't have to use Lock() here because plusings are read
// before threads are started
void * Plugin : : LoadInitFun ( const char * filename , Fun1 & fun_init )
{
void * p = dlopen ( filename , RTLD_NOW | RTLD_LOCAL ) ;
@ -265,7 +285,11 @@ void Plugin::Call(Session * ses, int message, Slots::iterator & slot, PluginInfo
if ( ! slot - > second . is_running )
{
if ( config - > log_plugin_call )
{
Lock ( ) ;
log < < log1 < < " Plugin: calling plugin id: " < < slot - > second . index < < " , message: " < < message < < logend ;
Unlock ( ) ;
}
slot - > second . is_running = true ;
@ -278,15 +302,21 @@ void Plugin::Call(Session * ses, int message, Slots::iterator & slot, PluginInfo
slot - > second . is_running = false ;
if ( config - > log_plugin_call )
{
Lock ( ) ;
log < < log1 < < " Plugin: returning from plugin id: " < < slot - > second . index < < " , message: " < < message
< < " , result: " < < ( info . res ? " true " : " false " ) < < logend ;
Unlock ( ) ;
}
}
else
{
Lock ( ) ;
log < < log1 < < " Plugin: id: " < < slot - > second . index
< < " , message: " < < message
< < " , recurrences are not allowed " < < logend ;
Unlock ( ) ;
}
}
@ -430,10 +460,10 @@ size_t Plugin::Size()
/*
! ! IMPROVE ME
Assign ( ) can work only if other threads are not started
we can add some barrier / flag so when other threads starts
then we cannot use Assign ( ) method
! ! IMPROVE ME
Assign ( ) can work only if other threads are not started
we can add some barrier / flag so when other threads starts
then we cannot use Assign ( ) method
*/
void Plugin : : Assign ( int message , Fun1 fun1 )
{