~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/kernel/src/code_server.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%%
4
 
%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
 
4
%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
5
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
32
32
 
33
33
-import(lists, [foreach/2]).
34
34
 
 
35
-define(ANY_NATIVE_CODE_LOADED, any_native_code_loaded).
 
36
 
35
37
-record(state, {supervisor,
36
38
                root,
37
39
                path,
97
99
                State0
98
100
        end,
99
101
 
 
102
    put(?ANY_NATIVE_CODE_LOADED, false),
 
103
 
100
104
    Parent ! {Ref,{ok,self()}},
101
105
    loop(State#state{supervisor = Parent}).
102
106
 
1278
1282
    %% Therefore we must test for that the loader modules are available
1279
1283
    %% before trying to to load native code.
1280
1284
    case erlang:module_loaded(hipe_unified_loader) of
1281
 
        false -> no_native;
1282
 
        true -> hipe_unified_loader:load_native_code(Mod, Bin)
 
1285
        false ->
 
1286
            no_native;
 
1287
        true ->
 
1288
            Result = hipe_unified_loader:load_native_code(Mod, Bin),
 
1289
            case Result of
 
1290
                {module,_} ->
 
1291
                    put(?ANY_NATIVE_CODE_LOADED, true);
 
1292
                _ ->
 
1293
                    ok
 
1294
            end,
 
1295
            Result
1283
1296
    end.
1284
1297
 
1285
1298
hipe_result_to_status(Result) ->
1286
1299
    case Result of
1287
 
        {module,_} -> Result;
1288
 
        _ -> {error,Result}
 
1300
        {module,_} ->
 
1301
            put(?ANY_NATIVE_CODE_LOADED, true),
 
1302
            Result;
 
1303
        _ ->
 
1304
            {error,Result}
1289
1305
    end.
1290
1306
 
1291
1307
post_beam_load(Mod) ->
1292
 
    case erlang:module_loaded(hipe_unified_loader) of
1293
 
        false -> ok;
1294
 
        true -> hipe_unified_loader:post_beam_load(Mod)
 
1308
    %% post_beam_load/1 can potentially be very expensive because it
 
1309
    %% blocks multi-scheduling; thus we want to avoid the call if we
 
1310
    %% know that it is not needed.
 
1311
    case get(?ANY_NATIVE_CODE_LOADED) of
 
1312
        true -> hipe_unified_loader:post_beam_load(Mod);
 
1313
        false -> ok
1295
1314
    end.
1296
1315
 
1297
1316
int_list([H|T]) when is_integer(H) -> int_list(T);
1379
1398
%%  Kill all processes running code from *old* Module, and then purge the
1380
1399
%%  module. Return true if any processes killed, else false.
1381
1400
 
1382
 
do_purge(Mod) ->
1383
 
    do_purge(processes(), to_atom(Mod), false).
 
1401
do_purge(Mod0) ->
 
1402
    Mod = to_atom(Mod0),
 
1403
    case erlang:check_old_code(Mod) of
 
1404
        false -> false;
 
1405
        true -> do_purge(processes(), Mod, false)
 
1406
    end.
1384
1407
 
1385
1408
do_purge([P|Ps], Mod, Purged) ->
1386
1409
    case erlang:check_process_code(P, Mod) of
1399
1422
    Purged.
1400
1423
 
1401
1424
%% do_soft_purge(Module)
1402
 
%% Purge old code only if no procs remain that run old code
 
1425
%% Purge old code only if no procs remain that run old code.
1403
1426
%% Return true in that case, false if procs remain (in this
1404
1427
%% case old code is not purged)
1405
1428
 
1406
1429
do_soft_purge(Mod) ->
1407
 
    catch do_soft_purge(processes(), Mod).
 
1430
    case erlang:check_old_code(Mod) of
 
1431
        false -> true;
 
1432
        true -> do_soft_purge(processes(), Mod)
 
1433
    end.
1408
1434
 
1409
1435
do_soft_purge([P|Ps], Mod) ->
1410
1436
    case erlang:check_process_code(P, Mod) of
1411
 
        true -> throw(false);
 
1437
        true -> false;
1412
1438
        false -> do_soft_purge(Ps, Mod)
1413
1439
    end;
1414
1440
do_soft_purge([], Mod) ->