Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
ecache
ecache_server-delete-reaper-process-in-handle_c...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ecache_server-delete-reaper-process-in-handle_call.patch of Package ecache
From db841c2804f12f4d1fa04bd20f5e6e0519006f28 Mon Sep 17 00:00:00 2001 From: Led <ledest@gmail.com> Date: Thu, 24 Mar 2016 12:03:04 +0200 Subject: [PATCH] ecache_server: delete reaper process in handle_call(empty, ...) and handle_call(reap_oldest, ...) --- src/ecache_server.erl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ecache_server.erl b/src/ecache_server.erl index 53a2683..ff2be81 100644 --- a/src/ecache_server.erl +++ b/src/ecache_server.erl @@ -120,6 +120,9 @@ handle_call(stats, _From, #cache{datum_index = DatumIndex} = State) -> {reply, Stats, State}; handle_call(empty, _From, #cache{datum_index = DatumIndex} = State) -> + lists:foreach(fun([Reaper]) when is_pid(Reaper) -> exit(Reaper, kill); + (_) -> ok + end, ets:match(DatumIndex, #datum{_ = '_', ttl_reaper = '$1'})), ets:delete_all_objects(DatumIndex), {reply, ok, State}; @@ -129,7 +132,7 @@ handle_call(reap_oldest, _From, #cache{datum_index = DatumIndex} = State) -> (_, Acc) -> Acc end, DatumNow, DatumIndex) of DatumNow -> true; - LeastActive -> ets:delete_object(DatumIndex, LeastActive) + LeastActive -> delete_object(DatumIndex, LeastActive) end, {reply, ok, State}; @@ -212,12 +215,14 @@ unkey({ecache_multi, {M, F, A}}) -> {M, F, A}. delete_datum(DatumIndex, Key) -> case ets:lookup(DatumIndex, Key) of - [#datum{ttl_reaper = Reaper} = Datum] -> - ets:delete_object(DatumIndex, Datum), - is_pid(Reaper) andalso exit(Reaper, kill); + [Datum] -> delete_object(DatumIndex, Datum); _ -> ok end. +delete_object(DatumIndex, #datum{ttl_reaper = Reaper} = Datum) -> + ets:delete_object(DatumIndex, Datum), + is_pid(Reaper) andalso exit(Reaper, kill). + -compile({inline, [{create_datum, 4}]}). create_datum(DatumKey, Data, TTL, Type) -> Timestamp = os:timestamp(), -- 2.1.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor