Skip to content

Commit

Permalink
Correct the type of the disk log header
Browse files Browse the repository at this point in the history
Thanks to Niclas Eklund.
  • Loading branch information
uabboli committed Jul 2, 2012
1 parent 3b34580 commit 5c32f22
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
7 changes: 5 additions & 2 deletions lib/kernel/src/disk_log.erl
Expand Up @@ -282,7 +282,8 @@ change_notify(Log, Pid, NewNotify) ->

-spec change_header(Log, Header) -> 'ok' | {'error', Reason} when
Log :: log(),
Header :: {head, dlog_head_opt()} | {head_func, mfa()},
Header :: {head, dlog_head_opt()}
| {head_func, MFA :: {atom(), atom(), list()}},
Reason :: no_such_log | nonode | {read_only_mode, Log}
| {blocked_log, Log} | {badarg, head}.
change_header(Log, NewHead) ->
Expand Down Expand Up @@ -336,7 +337,9 @@ format_error(Error) ->
ok | {blocked, QueueLogRecords :: boolean()}}
| {node, Node :: node()}
| {distributed, Dist :: local | [node()]}
| {head, Head :: none | {head, term()} | mfa()}
| {head, Head :: none
| {head, term()}
| (MFA :: {atom(), atom(), list()})}
| {no_written_items, NoWrittenItems ::non_neg_integer()}
| {full, Full :: boolean}
| {no_current_bytes, non_neg_integer()}
Expand Down
4 changes: 2 additions & 2 deletions lib/kernel/src/disk_log.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -74,7 +74,7 @@
| {distributed, Nodes :: [node()]}
| {notify, boolean()}
| {head, Head :: dlog_head_opt()}
| {head_func, mfa()}
| {head_func, MFA :: {atom(), atom(), list()}}
| {mode, Mode :: dlog_mode()}.
-type dlog_options() :: [dlog_option()].
-type dlog_repair() :: 'truncate' | boolean().
Expand Down
24 changes: 20 additions & 4 deletions lib/kernel/test/disk_log_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -90,7 +90,7 @@

evil/1,

otp_6278/1]).
otp_6278/1, otp_10131/1]).

-export([head_fun/1, hf/0, lserv/1,
measure/0, init_m/1, xx/0, head_exit/0, slow_header/1]).
Expand Down Expand Up @@ -124,7 +124,7 @@
[halt_int, wrap_int, halt_ext, wrap_ext, read_mode, head,
notif, new_idx_vsn, reopen, block, unblock, open, close,
error, chunk, truncate, many_users, info, change_size,
change_attribute, distribution, evil, otp_6278]).
change_attribute, distribution, evil, otp_6278, otp_10131]).

%% The following two lists should be mutually exclusive. To skip a case
%% on VxWorks altogether, use the kernel.spec.vxworks file instead.
Expand Down Expand Up @@ -153,7 +153,7 @@ all() ->
{group, open}, {group, close}, {group, error}, chunk,
truncate, many_users, {group, info},
{group, change_size}, change_attribute,
{group, distribution}, evil, otp_6278].
{group, distribution}, evil, otp_6278, otp_10131].

groups() ->
[{halt_int, [], [halt_int_inf, {group, halt_int_sz}]},
Expand Down Expand Up @@ -4915,6 +4915,22 @@ otp_6278(Conf) when is_list(Conf) ->
end,
?line error_logger:delete_report_handler(?MODULE).

otp_10131(suite) -> [];
otp_10131(doc) -> ["OTP-10131. head_func type."];
otp_10131(Conf) when is_list(Conf) ->
Dir = ?privdir(Conf),
Log = otp_10131,
File = filename:join(Dir, lists:concat([Log, ".LOG"])),
HeadFunc = {?MODULE, head_fun, [{ok,"head"}]},
{ok, Log} = disk_log:open([{name,Log},{file,File},
{head_func, HeadFunc}]),
HeadFunc = info(Log, head, undef),
HeadFunc2 = {?MODULE, head_fun, [{ok,"head2"}]},
ok = disk_log:change_header(Log, {head_func, HeadFunc2}),
HeadFunc2 = info(Log, head, undef),
ok = disk_log:close(Log),
ok.

mark(FileName, What) ->
{ok,Fd} = file:open(FileName, [raw, binary, read, write]),
{ok,_} = file:position(Fd, 4),
Expand Down

0 comments on commit 5c32f22

Please sign in to comment.