~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/ssh/src/ssh_connection_manager.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%% 
4
 
%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
 
4
%% Copyright Ericsson AB 2008-2010. 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
146
146
close(ConnectionManager, ChannelId) ->
147
147
    try   call(ConnectionManager, {close, ChannelId}) of
148
148
          ok ->
 
149
            ok;
 
150
          {error, channel_closed} ->
149
151
            ok
150
152
    catch
151
153
        exit:{noproc, _} ->
155
157
stop(ConnectionManager) ->
156
158
    try call(ConnectionManager, stop) of
157
159
        ok ->
 
160
            ok;
 
161
        {error, channel_closed} ->
158
162
            ok
159
163
    catch
160
164
        exit:{noproc, _} ->
178
182
%%                         {stop, Reason}
179
183
%% Description: Initiates the server
180
184
%%--------------------------------------------------------------------
181
 
init([server, _Socket, Opts]) ->  
 
185
init([server, _Socket, Opts, SubSysSup]) ->  
182
186
    process_flag(trap_exit, true),
183
187
    ssh_bits:install_messages(ssh_connection:messages()),
184
188
    Cache = ssh_channel:cache_create(), 
187
191
                                               channel_id_seed = 0,
188
192
                                               port_bindings = [],
189
193
                                               requests = [],
190
 
                                               channel_pids = []},
 
194
                                               channel_pids = [],
 
195
                                               sub_system_supervisor = SubSysSup},
191
196
                opts = Opts,
192
197
                connected = false}};
193
198
 
272
277
            {stop, normal, State#state{connection_state = Connection}}
273
278
        catch
274
279
        exit:{noproc, Reason} ->
275
 
            Report = io_lib:format("Connection probably terminated:~n~p~n~p~n",
276
 
                                   [ConnectionMsg, Reason]),
 
280
            Report = io_lib:format("Connection probably terminated:~n~p~n~p~n~p~n",
 
281
                                   [ConnectionMsg, Reason, erlang:get_stacktrace()]),
277
282
            error_logger:info_report(Report),
278
283
            {noreply, State};
279
284
        error:Error ->
280
 
            Report = io_lib:format("Connection message returned:~n~p~n~p~n",
281
 
                                   [ConnectionMsg, Error]),
 
285
            Report = io_lib:format("Connection message returned:~n~p~n~p~n~p~n",
 
286
                                   [ConnectionMsg, Error, erlang:get_stacktrace()]),
282
287
            error_logger:info_report(Report),
283
288
            {noreply, State};
284
289
        exit:Exit ->
285
 
            Report = io_lib:format("Connection message returned:~n~p~n~p~n",
286
 
                                   [ConnectionMsg, Exit]),
 
290
            Report = io_lib:format("Connection message returned:~n~p~n~p~n~p~n",
 
291
                                   [ConnectionMsg, Exit, erlang:get_stacktrace()]),
287
292
            error_logger:info_report(Report),
288
293
            {noreply, State}
289
294
    end;
400
405
    end;
401
406
 
402
407
handle_call(stop, _, #state{role = _client, 
403
 
                            client = ChannelPid,
 
408
                            client = _ChannelPid,
404
409
                            connection = Pid} = State) ->
405
410
    DisconnectMsg = 
406
411
        #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION,
555
560
%% The return value is ignored.
556
561
%%--------------------------------------------------------------------
557
562
terminate(Reason, #state{connection_state =  
558
 
                         #connection{requests = Requests},
 
563
                         #connection{requests = Requests,
 
564
                                    sub_system_supervisor = SubSysSup},
559
565
                         opts = Opts}) ->
560
566
    SSHOpts = proplists:get_value(ssh_opts, Opts),
561
567
    disconnect_fun(Reason, SSHOpts),
562
568
    (catch lists:foreach(fun({_, From}) -> 
563
569
                                 gen_server:reply(From, {error, connection_closed})
564
570
                         end, Requests)),
 
571
    Address =  proplists:get_value(address, Opts),
 
572
    Port = proplists:get_value(port, Opts),
 
573
    SystemSup = ssh_system_sup:system_supervisor(Address, Port),
 
574
    ssh_system_sup:stop_subsystem(SystemSup, SubSysSup),
565
575
    ok.
566
576
 
567
577
%%--------------------------------------------------------------------
592
602
            Result
593
603
    catch
594
604
        exit:{timeout, _} ->
595
 
            {error, timeout}
 
605
            {error, timeout};
 
606
        exit:{normal, _} ->
 
607
            {error, channel_closed}
596
608
    end.
597
609
 
598
610
cast(Pid, Msg) ->