File: SharedVariables.pm

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (55 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package Lemonldap::NG::Handler::Main::SharedVariables;

our $VERSION = '2.19.0';

# Since handler has no instance but only static classes, this module provides
# classes properties with accessors

package Lemonldap::NG::Handler::Main;

use strict;

BEGIN {
# Thread shared properties (if threads are available: needs to be loaded elsewhere)
    our $_tshv = {
        tsv          => {},
        cfgNum       => 0,
        cfgDate      => 0,
        checkMsg     => 5,
        lastCheck    => 0,
        lastCheckMsg => 0,
        checkTime    => 600,
        confAcc      => {},
        logger       => {},
        userLogger   => {},
        _auditLogger => {},
        lmConf       => {},
        localConfig  => {},
    };

    # Current sessions properties
    our $_v = { data => {}, dataUpdate => {}, };

    # Thread shared accessors
    foreach ( keys %$_tshv ) {
        eval " sub $_ {
            my \$v = \$_[1];
            \$_tshv->{$_} = \$v if (defined \$v);
            return \$_tshv->{$_};
        }";
        die $@ if ($@);
    }

    # Current session accessors
    eval "threads::shared::share(\$_tshv);";
    foreach ( keys %$_v ) {
        eval " sub $_ {
            my \$v = \$_[1];
            \$_v->{$_} = \$v if (\$v);
            return \$_v->{$_};
        }";
        die $@ if ($@);
    }
}

1;