~ubuntu-branches/ubuntu/saucy/rabbitmq-server/saucy-proposed

« back to all changes in this revision

Viewing changes to plugins-src/rabbitmq-erlang-client/src/amqp_connection.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2012-12-11 15:47:52 UTC
  • mfrom: (0.2.19) (0.1.33 sid)
  • Revision ID: package-import@ubuntu.com-20121211154752-gvq8tpx6tj3v89ek
Tags: 3.0.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
%% the default ports will be selected depending on whether this is a
148
148
%% normal or an SSL connection.
149
149
start(AmqpParams) ->
150
 
    case amqp_client:start() of
151
 
        ok                                      -> ok;
152
 
        {error, {already_started, amqp_client}} -> ok;
153
 
        {error, _} = E                          -> throw(E)
154
 
    end,
 
150
    ensure_started(),
155
151
    AmqpParams1 =
156
152
        case AmqpParams of
157
153
            #amqp_params_network{port = undefined, ssl_options = none} ->
164
160
    {ok, _Sup, Connection} = amqp_sup:start_connection_sup(AmqpParams1),
165
161
    amqp_gen_connection:connect(Connection).
166
162
 
 
163
%% Usually the amqp_client application will already be running. We
 
164
%% check whether that is the case by invoking an undocumented function
 
165
%% which does not require a synchronous call to the application
 
166
%% controller. That way we don't risk a dead-lock if, say, the
 
167
%% application controller is in the process of shutting down the very
 
168
%% application which is making this call.
 
169
ensure_started() ->
 
170
    case application_controller:get_master(amqp_client) of
 
171
        undefined ->
 
172
            case amqp_client:start() of
 
173
                ok                                      -> ok;
 
174
                {error, {already_started, amqp_client}} -> ok;
 
175
                {error, _} = E                          -> throw(E)
 
176
            end;
 
177
        _ ->
 
178
            ok
 
179
    end.
 
180
 
167
181
%%---------------------------------------------------------------------------
168
182
%% Commands
169
183
%%---------------------------------------------------------------------------