Permalink
Browse files

Fix time-fudging code to be 100% deterministic

  • Loading branch information...
1 parent dec7f03 commit 7508d884c4272481ccb2685257ae8f84952d2b30 @slfritchie slfritchie committed Nov 9, 2012
Showing with 4 additions and 5 deletions.
  1. +2 −0 rebar.config
  2. +2 −5 src/bitcask_time.erl
View
@@ -66,6 +66,8 @@
%% , {bitcask_nifs, file_write, 2}
%% , {bitcask_nifs, file_seekbof, 1}
%%
+ %% , {bitcask_time, tstamp, 0}
+ %%
%% , {file, '_', '_'}
%% , {filelib, '_', '_'}
%% , {os, '_', '_'} ]},
@@ -28,10 +28,6 @@
%% Return number of seconds since 1970
tstamp() ->
- {Mega, Sec, _Micro} = os:timestamp(),
- (Mega * 1000000) + Sec + fudge().
-
-fudge() ->
test__get(?KEY).
test__set_fudge(Amount) ->
@@ -56,7 +52,8 @@ test__get(Key) ->
end,
test__get(Key);
no_testing ->
- 0;
+ {Mega, Sec, _Micro} = os:timestamp(),
+ (Mega * 1000000) + Sec;
yes_testing ->
{ok, Fudge} = application:get_env(bitcask, Key),
Fudge

0 comments on commit 7508d88

Please sign in to comment.