2016-03-17 23:19:44 +01:00
|
|
|
package Lemonldap::NG::Handler::Main::SharedVariables;
|
|
|
|
|
2017-02-08 23:18:52 +01:00
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
2016-03-17 23:19:44 +01:00
|
|
|
# Since handler has no instances but only static classes, this module provides
|
|
|
|
# classes properties with accessors
|
|
|
|
|
2017-02-08 23:18:52 +01:00
|
|
|
package Lemonldap::NG::Handler::Main;
|
2016-03-17 23:19:44 +01:00
|
|
|
|
2017-02-08 23:18:52 +01:00
|
|
|
use strict;
|
2016-03-17 23:19:44 +01:00
|
|
|
|
2017-02-13 12:58:39 +01:00
|
|
|
BEGIN {
|
2016-03-17 23:19:44 +01:00
|
|
|
# Thread shared properties (if threads are available: needs to be loaded elsewhere)
|
2017-02-13 12:58:39 +01:00
|
|
|
our $_tshv = {
|
|
|
|
tsv => {},
|
|
|
|
cfgNum => 0,
|
|
|
|
lastCheck => 0,
|
|
|
|
checkTime => 600,
|
|
|
|
confAcc => {},
|
|
|
|
logger => {},
|
|
|
|
userLogger => {},
|
|
|
|
lmConf => {},
|
|
|
|
localConfig => {},
|
|
|
|
};
|
|
|
|
|
|
|
|
# Current sessions properties
|
2017-03-28 23:07:49 +02:00
|
|
|
our $_v = { datas => {}, datasUpdate => {}, };
|
2016-03-17 23:19:44 +01:00
|
|
|
|
|
|
|
# Thread shared accessors
|
2017-02-13 12:58:39 +01:00
|
|
|
foreach ( keys %$_tshv ) {
|
2016-03-17 23:19:44 +01:00
|
|
|
eval " sub $_ {
|
|
|
|
my \$v = \$_[1];
|
|
|
|
\$_tshv->{$_} = \$v if(defined \$v);
|
|
|
|
return \$_tshv->{$_};
|
|
|
|
}";
|
|
|
|
die $@ if ($@);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Current session accessors
|
|
|
|
eval "threads::shared::share(\$_tshv);";
|
2017-02-13 12:58:39 +01:00
|
|
|
foreach ( keys %$_v ) {
|
2016-03-17 23:19:44 +01:00
|
|
|
eval " sub $_ {
|
|
|
|
my \$v = \$_[1];
|
|
|
|
\$_v->{$_} = \$v if(\$v);
|
|
|
|
return \$_v->{$_};
|
|
|
|
}";
|
2016-03-23 13:55:09 +01:00
|
|
|
die $@ if ($@);
|
2016-03-17 23:19:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|