~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/snmp/src/agent/snmpa_local_db.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
    dets:open_file(Name, Args).
212
212
 
213
213
    
 
214
dets_filename(Name, Dir) when is_atom(Name) ->
 
215
    dets_filename(atom_to_list(Name), Dir);
214
216
dets_filename(Name, Dir) ->
215
217
    filename:join(dets_filename1(Dir), Name).
216
218
    
909
911
match(volatile, Name, Pattern, #state{ets = Ets}) ->
910
912
    ets:match(Ets, {{Name,'_'},{Pattern,'_','_'}});
911
913
match(persistent, Name, Pattern, #state{dets = Dets}) ->
912
 
    case dets_match(Dets, {{Name,'_'},{Pattern,'_','_'}}) of
913
 
        {error, Reason} ->
914
 
            error_msg("DETS (persistent) match failed for {~w,~w}: ~n~w", 
915
 
                      [Name, Pattern, Reason]),
916
 
            [];
917
 
        Match ->
918
 
            Match
919
 
    end;
 
914
    dets_match(Dets, {{Name,'_'},{Pattern,'_','_'}});
920
915
match(permanent, Name, Pattern, #state{dets = Dets}) ->
921
 
    case dets_match(Dets, {{Name,'_'},{Pattern,'_','_'}})  of
922
 
        {error, Reason} ->
923
 
            error_msg("DETS (permanent) match failed for {~w,~w}: ~n~w", 
924
 
                      [Name, Pattern, Reason]),
925
 
            [];
926
 
        Match ->
927
 
            Match
928
 
    end;
 
916
    dets_match(Dets, {{Name,'_'},{Pattern,'_','_'}});
929
917
match(UnknownDb, Name, Pattern, _) ->
930
918
    error_msg("Tried to match [~p,~p] from unknown db ~w", 
931
919
              [Name, Pattern, UnknownDb]),
933
921
 
934
922
lookup(volatile, Key, #state{ets = Ets}) ->
935
923
    case ets:lookup(Ets, Key) of
936
 
        [{_, Val}] -> {value, Val};
937
 
        [] -> undefined
 
924
        [{_, Val}] -> 
 
925
            {value, Val};
 
926
        [] -> 
 
927
            undefined
938
928
    end;
939
929
lookup(persistent, Key, #state{dets = Dets}) ->
940
930
    case dets_lookup(Dets, Key) of
941
 
        [{_, Val}] -> {value, Val};
942
 
        [] -> undefined;
943
 
        {error, Reason} ->
944
 
            error_msg("DETS lookup of ~w failed: ~n~w", [Key, Reason]),
 
931
        [{_, Val}] -> 
 
932
            {value, Val};
 
933
        [] -> 
945
934
            undefined
946
935
    end;
947
936
lookup(permanent, Key, #state{dets = Dets}) ->
949
938
        [{_, Val}] -> 
950
939
            {value, Val};
951
940
        [] -> 
952
 
            undefined;
953
 
        {error, Reason} ->
954
 
            error_msg("DETS (permanent) lookup ~w failed: ~n~w", 
955
 
                      [Key, Reason]),
956
941
            undefined
957
942
    end;
958
943
lookup(UnknownDb, Key, _) ->