View | Details | Raw Unified | Return to bug 13431
Collapse All | Expand All

(-)a/Koha/Cache.pm (-12 / +22 lines)
Lines 40-46 use warnings; Link Here
40
use Carp;
40
use Carp;
41
use Module::Load::Conditional qw(can_load);
41
use Module::Load::Conditional qw(can_load);
42
use Koha::Cache::Object;
42
use Koha::Cache::Object;
43
use C4::Context;
44
43
45
use base qw(Class::Accessor);
44
use base qw(Class::Accessor);
46
45
Lines 161-176 sub _initialize_memcached { Link Here
161
160
162
sub _initialize_fastmmap {
161
sub _initialize_fastmmap {
163
    my ($self) = @_;
162
    my ($self) = @_;
164
    my $share_file = join( '-',
163
    my ($cache, $share_file);
165
        "/tmp/sharefile-koha", $self->{'namespace'},
164
166
        C4::Context->config('hostname'), C4::Context->config('database'),
165
    # Temporary workaround to catch fatal errors when: C4::Context module
167
        "" . getpwuid($>) );
166
    # is not loaded beforehand, or Cache::FastMmap init fails for whatever
168
167
    # other reason (e.g. due to permission issues - see Bug 13431)
169
    $self->{'fastmmap_cache'} = Cache::FastMmap->new(
168
    eval {
170
        'share_file'  => $share_file,
169
        $share_file = join( '-',
171
        'expire_time' => $self->{'timeout'},
170
            "/tmp/sharefile-koha", $self->{'namespace'},
172
        'unlink_on_exit' => 0,
171
            C4::Context->config('hostname'), C4::Context->config('database') );
173
    );
172
173
        $cache = Cache::FastMmap->new(
174
            'share_file'  => $share_file,
175
            'expire_time' => $self->{'timeout'},
176
            'unlink_on_exit' => 0,
177
        );
178
    };
179
    if ( $@ ) {
180
        warn "FastMmap cache initialization failed: $@";
181
        return;
182
    }
183
    return unless defined $cache;
184
    $self->{'fastmmap_cache'} = $cache;
174
    return $self;
185
    return $self;
175
}
186
}
176
187
177
- 

Return to bug 13431