Skip to content

Commit

Permalink
fix timer for #pi
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Mar 7, 2019
1 parent 0ab699c commit c4b9017
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/n2o.erl
Expand Up @@ -123,17 +123,17 @@ error_page(Class,Error) ->

% TIMER

proc(init,#handler{}=Async) ->
proc(init,#pi{}=Async) ->
n2o:info(?MODULE,"Proc Init: ~p\r~n",[init]),
Timer = timer_restart(ping()),
{ok,Async#handler{state=Timer}};
{ok,Async#pi{state=Timer}};

proc({timer,ping},#handler{state=Timer}=Async) ->
proc({timer,ping},#pi{state=Timer}=Async) ->
erlang:cancel_timer(Timer),
n2o:info(?MODULE,"n2o Timer: ~p\r~n",[ping]),
n2o:invalidate_cache(caching),
(n2o_session:storage()):invalidate_sessions(),
{reply,ok,Async#handler{state=timer_restart(ping())}}.
{reply,ok,Async#pi{state=timer_restart(ping())}}.

invalidate_cache(Table) -> ets:foldl(fun(X,_) -> n2o:cache(Table,element(1,X)) end, 0, Table).
timer_restart(Diff) -> {X,Y,Z} = Diff, erlang:send_after(1000*(Z+60*Y+60*60*X),self(),{timer,ping}).
Expand Down

0 comments on commit c4b9017

Please sign in to comment.